Frank Nimphius' Blogbuster: J2EE Security: Dynamic user creation for container managed authentication

Frank Nimphiusのブログに以下のような記事がありました。

The gap in J2EE and JAAS authentication
One aspect of authentication that is not covered in the J2EE specs is account management like account creation. Generally the J2EE and JAAS specs lack any API and Interface definition of how user account management is supposed to happen, which I think is a first grade omission. In my opinion there should be a standard API defined that includes user APIs for the developer to use in his applications to perform account management tasks like
user registration
account revocation
account management
The above would enable developers to delegate all account management related tasks to the J2EE container without having to write to container specific - and thus proprietary - APIs.

J2EEの仕様にもJAASの仕様にもアカウント作成などのアカウント管理のAPIはないのがネックだとしています。
そこで、とりあえずOracleASのJ2EEコンテナであるOC4Jではどのようにしたら拡張できるかについてのお話とサンプルコードが提示されています。
さて、ではサンプルコードの中では何をやってるかと思い調べてみました。

    // Note: The orion user manager used in this example is subject to 
    // replacement in a later release of OC4J. However, for now it provides
    // us with the required functionality

    JAZNUserManager _userMgr = (JAZNUserManager) request.getSession().getServletContext().getAttribute("user.manager");

    // create the new user
    try
    {
      // create the user 
      User _newUser = _userMgr.createUser(_username,_password);
      
      // groups in jazn-data.xml are roles 
      // Note: An IllegalArgument exception is thrown 
      // if the group name doesn't exist in the jazn-data.xml 
      // file
      
      try 
      {
        _newUser.addToGroup(_userMgr.getGroup(_role));
        
      } catch (java.lang.IllegalArgumentException iae) 
      {
        ...
      }
      ...
    }

というかたちで、サーブレットコンテキストからUserManagerを引っ張ってきています。

ただ、このようにしてUserManagerにアクセスできるということは、マニュアルなどに明記されているものではないので、今後仕様の変更が発生した場合などに対処が難しそうです。使用するには注意が必要です。