1 21 22 package org.apache.derby.impl.jdbc.authentication; 23 24 import org.apache.derby.iapi.services.context.ContextService; 25 import org.apache.derby.iapi.error.StandardException; 26 27 import org.apache.derby.iapi.store.access.AccessFactory; 28 import org.apache.derby.iapi.store.access.TransactionController; 29 30 import org.apache.derby.iapi.jdbc.AuthenticationService; 31 import org.apache.derby.authentication.UserAuthenticator; 32 33 import org.apache.derby.iapi.services.sanity.SanityManager; 34 import org.apache.derby.iapi.reference.SQLState; 35 import org.apache.derby.iapi.error.ExceptionSeverity; 36 import org.apache.derby.iapi.reference.MessageId; 37 import org.apache.derby.iapi.services.i18n.MessageService; 38 39 import java.util.Properties ; 40 import java.util.Enumeration ; 41 import java.sql.SQLException ; 42 43 53 54 public abstract class JNDIAuthenticationSchemeBase implements UserAuthenticator 55 { 56 protected final JNDIAuthenticationService authenticationService; 57 protected String providerURL; 58 59 private AccessFactory store; 60 protected Properties initDirContextEnv; 61 62 public JNDIAuthenticationSchemeBase(JNDIAuthenticationService as, Properties dbProperties) { 69 70 this.authenticationService = as; 71 72 setInitDirContextEnv(dbProperties); 78 79 this.setJNDIProviderProperties(); 81 } 82 83 84 89 abstract protected void setJNDIProviderProperties(); 90 91 97 private void setInitDirContextEnv(Properties dbProps) { 98 99 initDirContextEnv = new Properties (); 105 106 if(dbProps != null) { 107 for (Enumeration keys = dbProps.propertyNames(); keys.hasMoreElements(); ) { 108 109 String key = (String ) keys.nextElement(); 110 111 if (key.startsWith("java.naming.")) { 112 initDirContextEnv.put(key, dbProps.getProperty(key)); 113 } 114 } 115 } 116 } 117 118 protected static final SQLException getLoginSQLException(Exception e) { 119 120 String text = MessageService.getTextMessage(SQLState.LOGIN_FAILED, e); 121 122 SQLException sqle = new SQLException ( 123 text, SQLState.LOGIN_FAILED, ExceptionSeverity.SESSION_SEVERITY); 124 125 return sqle; 126 } 127 128 } 129 | Popular Tags |