1 21 22 package org.apache.derby.impl.jdbc.authentication; 23 24 import org.apache.derby.iapi.reference.SQLState; 25 import org.apache.derby.iapi.reference.ClassName; 26 27 import org.apache.derby.iapi.error.StandardException; 28 import org.apache.derby.iapi.jdbc.AuthenticationService; 29 import org.apache.derby.iapi.util.StringUtil; 30 import org.apache.derby.authentication.UserAuthenticator; 31 32 import org.apache.derby.iapi.services.property.PropertyUtil; 33 34 import java.util.Properties ; 35 36 45 public class SpecificAuthenticationServiceImpl 46 extends AuthenticationServiceBase { 47 48 private String specificAuthenticationScheme; 49 50 54 57 public boolean canSupport(Properties properties) { 58 59 if (!requireAuthentication(properties)) 70 return false; 71 72 specificAuthenticationScheme = PropertyUtil.getPropertyFromSet( 73 properties, 74 org.apache.derby.iapi.reference.Property.AUTHENTICATION_PROVIDER_PARAMETER); 75 if ( 76 ((specificAuthenticationScheme != null) && 77 (specificAuthenticationScheme.length() != 0) && 78 79 (!((StringUtil.SQLEqualsIgnoreCase(specificAuthenticationScheme, 80 org.apache.derby.iapi.reference.Property.AUTHENTICATION_PROVIDER_BUILTIN)) || 81 (specificAuthenticationScheme.equalsIgnoreCase( 82 org.apache.derby.iapi.reference.Property.AUTHENTICATION_PROVIDER_LDAP)) )))) 83 return true; 84 else 85 return false; 86 } 87 88 93 public void boot(boolean create, Properties properties) 94 throws StandardException { 95 96 99 super.boot(create, properties); 101 102 111 Throwable t; 112 try { 113 114 Class sasClass = Class.forName(specificAuthenticationScheme); 115 if (!UserAuthenticator.class.isAssignableFrom(sasClass)) { 116 throw StandardException.newException(SQLState.AUTHENTICATION_NOT_IMPLEMENTED, 117 specificAuthenticationScheme, "org.apache.derby.authentication.UserAuthenticator"); 118 } 119 120 UserAuthenticator aScheme = (UserAuthenticator) sasClass.newInstance(); 121 122 this.setAuthenticationService(aScheme); 126 127 return; 128 129 } catch (ClassNotFoundException cnfe) { 130 t = cnfe; 131 } catch (InstantiationException ie) { 132 t = ie; 133 } catch (IllegalAccessException iae) { 134 t = iae; 135 } 136 throw StandardException.newException(SQLState.AUTHENTICATION_SCHEME_ERROR, t, 137 specificAuthenticationScheme); 138 } 139 } 140 | Popular Tags |