Class KerberosCredentialProvider
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.authentication.AbstractCredentialProvider
-
- org.ametys.plugins.extrausermgt.authentication.kerberos.KerberosCredentialProvider
-
- All Implemented Interfaces:
CredentialProvider,NonBlockingCredentialProvider,LogEnabled,Component,Contextualizable
public class KerberosCredentialProvider extends AbstractCredentialProvider implements NonBlockingCredentialProvider, Contextualizable
Kerberos http authentication.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String__LOGIN_CONF_FILEName of the login config fileprotected static String__PARAM_IPRESTRICTIONName of the parameter holding the regexp to match ip adressesprotected static String__PARAM_KDCName of the parameter holding the authentication server kdc adressprotected static String__PARAM_LOGINName of the parameter holding the ametys loginprotected static String__PARAM_PASSWORDName of the parameter holding the ametys passwordprotected static String__PARAM_REALMName of the parameter holding the authentication server realmprotected static String__SESSION_ATTRIBUTE_GSSCONTEXTKerberos contextprotected static String__SKIP_KERBEROS_URLThe url to redirect to skip kerberos current authentication
-
Constructor Summary
Constructors Constructor Description KerberosCredentialProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcontextualize(Context context)static LoginContextcreateLoginContext(String kdc, String realm, String login, String password, Context context)Create a logged in LoginContext for Kerberosvoidinit(String id, String cpModelId, Map<String,Object> paramValues, String label)Initialize the credential provider with given parameters' values.UserIdentitynonBlockingGetUserIdentity(Redirector redirector)Method called by AuthenticateAction each time a request need authentication.booleannonBlockingGrantAnonymousRequest()Method called by AuthenticateAction before asking for credentials.booleannonBlockingIsStillConnected(UserIdentity userIdentity, Redirector redirector)Validates that the user specify is still connectedvoidnonBlockingUserAllowed(UserIdentity userIdentity, Redirector redirector)Method called by AuthenticateAction after authentication process succeededvoidnonBlockingUserNotAllowed(Redirector redirector)Method called by AuthenticateAction each a user could not get authenticated.-
Methods inherited from class org.ametys.core.authentication.AbstractCredentialProvider
equals, getCredentialProviderModelId, getId, getLabel, getParameterValues, hashCode
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.core.authentication.CredentialProvider
getCredentialProviderModelId, getId, getLabel, getParameterValues, getUserIdentity, grantAnonymousRequest, isStillConnected, userAllowed, userNotAllowed
-
-
-
-
Field Detail
-
__PARAM_KDC
protected static final String __PARAM_KDC
Name of the parameter holding the authentication server kdc adress- See Also:
- Constant Field Values
-
__PARAM_REALM
protected static final String __PARAM_REALM
Name of the parameter holding the authentication server realm- See Also:
- Constant Field Values
-
__PARAM_LOGIN
protected static final String __PARAM_LOGIN
Name of the parameter holding the ametys login- See Also:
- Constant Field Values
-
__PARAM_PASSWORD
protected static final String __PARAM_PASSWORD
Name of the parameter holding the ametys password- See Also:
- Constant Field Values
-
__PARAM_IPRESTRICTION
protected static final String __PARAM_IPRESTRICTION
Name of the parameter holding the regexp to match ip adresses- See Also:
- Constant Field Values
-
__LOGIN_CONF_FILE
protected static final String __LOGIN_CONF_FILE
Name of the login config file- See Also:
- Constant Field Values
-
__SKIP_KERBEROS_URL
protected static final String __SKIP_KERBEROS_URL
The url to redirect to skip kerberos current authentication- See Also:
- Constant Field Values
-
__SESSION_ATTRIBUTE_GSSCONTEXT
protected static final String __SESSION_ATTRIBUTE_GSSCONTEXT
Kerberos context- See Also:
- Constant Field Values
-
-
Constructor Detail
-
KerberosCredentialProvider
public KerberosCredentialProvider()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
createLoginContext
public static LoginContext createLoginContext(String kdc, String realm, String login, String password, Context context) throws IOException, LoginException, ContextException
Create a logged in LoginContext for Kerberos- Parameters:
kdc- The key distribution centerrealm- The realmlogin- The identifier of a user to the kdcpassword- The associated passwordcontext- The avalong context- Returns:
- A non null LoginContext (to be logged out)
- Throws:
IOException- If an error occurred while creating a temporary configuration file on the diskLoginException- If the login process failedContextException- If an error occurred while getting cocoon environment from context
-
init
public void init(String id, String cpModelId, Map<String,Object> paramValues, String label)
Description copied from interface:CredentialProviderInitialize the credential provider with given parameters' values.- Specified by:
initin interfaceCredentialProvider- Overrides:
initin classAbstractCredentialProvider- Parameters:
id- The unique identifiercpModelId- The id of credential provider extension pointparamValues- The parameters' valueslabel- The specific label of this instance. Can be null
-
nonBlockingIsStillConnected
public boolean nonBlockingIsStillConnected(UserIdentity userIdentity, Redirector redirector) throws Exception
Description copied from interface:NonBlockingCredentialProviderValidates that the user specify is still connected- Specified by:
nonBlockingIsStillConnectedin interfaceNonBlockingCredentialProvider- Parameters:
userIdentity- the user previously correctly identified with this credential providerredirector- The cocoon redirector- Returns:
- true if this CredentialProvider was in a valid state, false to restart authentication process
- Throws:
Exception- If an error occurred
-
nonBlockingGrantAnonymousRequest
public boolean nonBlockingGrantAnonymousRequest()
Description copied from interface:NonBlockingCredentialProviderMethod called by AuthenticateAction before asking for credentials. This method is used to bypass authentication. If this method returns true, no authentication will be require. Use it with care, as it may lead to obvious security issues.- Specified by:
nonBlockingGrantAnonymousRequestin interfaceNonBlockingCredentialProvider- Returns:
- true if the Request is not authenticated
-
nonBlockingGetUserIdentity
public UserIdentity nonBlockingGetUserIdentity(Redirector redirector) throws Exception
Description copied from interface:NonBlockingCredentialProviderMethod called by AuthenticateAction each time a request need authentication.- Specified by:
nonBlockingGetUserIdentityin interfaceNonBlockingCredentialProvider- Parameters:
redirector- the cocoon redirector.- Returns:
- the
UserIdentitycorresponding to the user (with or without population specified), or null if user could not get authenticated. - Throws:
Exception- if something wrong occurs
-
nonBlockingUserNotAllowed
public void nonBlockingUserNotAllowed(Redirector redirector)
Description copied from interface:NonBlockingCredentialProviderMethod called by AuthenticateAction each a user could not get authenticated. This method implementation is responsible of redirecting response to appropriate url.- Specified by:
nonBlockingUserNotAllowedin interfaceNonBlockingCredentialProvider- Parameters:
redirector- the cocoon Redirector that can be used for redirecting response.
-
nonBlockingUserAllowed
public void nonBlockingUserAllowed(UserIdentity userIdentity, Redirector redirector)
Description copied from interface:NonBlockingCredentialProviderMethod called by AuthenticateAction after authentication process succeeded- Specified by:
nonBlockingUserAllowedin interfaceNonBlockingCredentialProvider- Parameters:
userIdentity- The user correctly connectedredirector- the cocoon Redirector that can be used for redirecting response.
-
-