Created
June 24, 2018 14:33
-
-
Save pubudu94/23a2bf5a673150fc43daeb4aa65325fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.weblogic.security; | |
import weblogic.management.security.ProviderMBean; | |
import weblogic.security.provider.PrincipalValidatorImpl; | |
import weblogic.security.spi.AuthenticationProvider; | |
import weblogic.security.spi.IdentityAsserter; | |
import weblogic.security.spi.PrincipalValidator; | |
import weblogic.security.spi.SecurityServices; | |
import javax.security.auth.login.AppConfigurationEntry; | |
import java.util.HashMap; | |
public final class SampleAuthenticationProvider implements AuthenticationProvider { | |
private String description; | |
// private SampleAuthenticatorDatabase database; | |
private AppConfigurationEntry.LoginModuleControlFlag controlFlag; | |
public void initialize(ProviderMBean mbean, SecurityServices services) { | |
System.out.println("SampleAuthenticationProviderImpl.initialize"); | |
/* SampleAuthenticatorMBean myMBean = (SampleAuthenticatorMBean)mbean; | |
description = myMBean.getDescription() + "\n" + myMBean.getVersion(); | |
database = new SampleAuthenticatorDatabase(myMBean); | |
String flag = myMBean.getControlFlag();*/ | |
String flag = "REQUIRED"; | |
if (flag.equalsIgnoreCase("REQUIRED")) { | |
controlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED; | |
} else if (flag.equalsIgnoreCase("OPTIONAL")) { | |
controlFlag = AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL; | |
} else if (flag.equalsIgnoreCase("REQUISITE")) { | |
controlFlag = AppConfigurationEntry.LoginModuleControlFlag.REQUISITE; | |
} else if (flag.equalsIgnoreCase("SUFFICIENT")) { | |
controlFlag = AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT; | |
} else { | |
throw new IllegalArgumentException("invalid flag value" + flag); | |
} | |
} | |
public String getDescription() { | |
return description; | |
} | |
public void shutdown() { | |
System.out.println("SampleAuthenticationProviderImpl.shutdown"); | |
} | |
private AppConfigurationEntry getConfiguration(HashMap options) { | |
// options.put("database", database); | |
return new | |
AppConfigurationEntry( | |
"com.weblogic.security.SampleLoginModule", | |
controlFlag, | |
options | |
); | |
} | |
public AppConfigurationEntry getLoginModuleConfiguration() { | |
HashMap options = new HashMap(); | |
return getConfiguration(options); | |
} | |
public AppConfigurationEntry getAssertionModuleConfiguration() { | |
HashMap options = new HashMap(); | |
options.put("IdentityAssertion", "true"); | |
return getConfiguration(options); | |
} | |
public PrincipalValidator getPrincipalValidator() { | |
return new PrincipalValidatorImpl(); | |
} | |
public IdentityAsserter getIdentityAsserter() { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment