use of com.sun.identity.authentication.internal.AuthPrincipal in project OpenAM by OpenRock.
the class UpdateDNSAlias method main.
public static void main(String[] args) {
if (args.length != 5) {
System.out.println(" Usage: UpdateDNSAlias " + "<add | delete> <orgdn> <dnsalias> <userdn> <passwd>");
System.exit(1);
}
String opt = args[0];
String orgDn = args[1];
String dnsAlias = args[2];
if ((opt == null) || (orgDn == null) || (dnsAlias == null)) {
debug.error("One or more parameters are null");
System.exit(1);
}
try {
String bindDN = args[3];
String password = args[4];
SSOTokenManager ssom = SSOTokenManager.getInstance();
SSOToken token = ssom.createSSOToken(new AuthPrincipal(bindDN), password);
AMStoreConnection asc = new AMStoreConnection(token);
AMOrganization org = asc.getOrganization(orgDn);
Set values = org.getAttribute("sunOrganizationAlias");
HashMap map = new HashMap();
if (opt.equalsIgnoreCase("add")) {
if (!values.contains(dnsAlias)) {
values.add(dnsAlias);
}
map.put("sunOrganizationAlias", values);
org.setAttributes(map);
org.store();
} else if (opt.equalsIgnoreCase("delete")) {
values.remove(dnsAlias);
map.put("sunOrganizationAlias", values);
org.setAttributes(map);
org.store();
} else {
debug.error("Unknown option in AMGenerateServerID");
System.exit(1);
}
} catch (Exception e) {
debug.error("Exception occured:", e);
}
System.exit(0);
}
use of com.sun.identity.authentication.internal.AuthPrincipal in project OpenAM by OpenRock.
the class AMGenerateServerID method main.
public static void main(String[] args) {
if (args.length != 4) {
System.out.println(" Usage: AMGenerateServerID create|delete " + "<serverurl> amadminDN amadminPassword");
System.exit(1);
}
String opt = args[0];
String serverUrl = args[1];
try {
String bindDN = args[2];
String password = args[3];
SSOTokenManager ssom = SSOTokenManager.getInstance();
SSOToken token = ssom.createSSOToken(new AuthPrincipal(bindDN), password);
Set servers = ServerConfiguration.getServerInfo(token);
for (Iterator iter = servers.iterator(); iter.hasNext(); ) {
String server = (String) iter.next();
if (server.startsWith(serverUrl)) {
debug.message("server already exists., exiting");
System.exit(0);
}
}
if (opt.equalsIgnoreCase("create")) {
if (debug.messageEnabled()) {
debug.message("New server entry:" + serverUrl);
}
ServerConfiguration.createServerInstance(token, serverUrl, Collections.EMPTY_SET, "");
} else if (opt.equalsIgnoreCase("delete")) {
if (ServerConfiguration.deleteServerInstance(token, serverUrl)) {
debug.message("Server entry to be removed:" + serverUrl);
} else {
debug.message("Can not find server in server's list:" + serverUrl);
System.exit(1);
}
} else {
debug.message("Unknown option in AMGenerateServerID");
System.exit(1);
}
} catch (Exception e) {
debug.error("Exception occured:", e);
}
}
use of com.sun.identity.authentication.internal.AuthPrincipal in project OpenAM by OpenRock.
the class InitializeSystem method getSSOToken.
public SSOToken getSSOToken(String bindPwd) throws LoginException, InvalidAuthContextException {
SSOToken ssoToken = null;
String userRootSuffix = bData.getUserBaseDN();
AuthPrincipal principal = new AuthPrincipal("cn=dsameuser,ou=DSAME Users," + userRootSuffix);
AuthContext ac = new AuthContext(userRootSuffix, principal, bindPwd.toCharArray());
if (ac.getLoginStatus() == AuthContext.AUTH_SUCCESS) {
ssoToken = ac.getSSOToken();
}
return ssoToken;
}
use of com.sun.identity.authentication.internal.AuthPrincipal in project OpenAM by OpenRock.
the class Bootstrap method getSSOToken.
private static SSOToken getSSOToken(String basedn, String bindUser, String bindPwd) throws LoginException, InvalidAuthContextException {
SSOToken ssoToken = null;
AuthPrincipal principal = new AuthPrincipal(bindUser);
AuthContext ac = new AuthContext(basedn, principal, bindPwd.toCharArray());
if (ac.getLoginStatus() == AuthContext.AUTH_SUCCESS) {
ssoToken = ac.getSSOToken();
}
return ssoToken;
}
use of com.sun.identity.authentication.internal.AuthPrincipal in project OpenAM by OpenRock.
the class SMSLdapObject method initialize.
/**
* Synchronized initialized method
*/
private synchronized void initialize() throws SMSException {
if (initialized) {
return;
}
// Obtain the I18N resource bundle & Debug
debug = Debug.getInstance("amSMSLdap");
AMResourceBundleCache amCache = AMResourceBundleCache.getInstance();
bundle = amCache.getResBundle(IUMSConstants.UMS_BUNDLE_NAME, java.util.Locale.ENGLISH);
OU_ATTR[0] = getNamingAttribute();
O_ATTR[0] = getOrgNamingAttribute();
String enableP = SystemProperties.get(SMSEntry.DB_PROXY_ENABLE);
enableProxy = (enableP != null) && enableP.equalsIgnoreCase("true");
if (debug.messageEnabled()) {
debug.message("SMSLdapObject: proxy enable value: " + enableProxy);
}
try {
if (enableProxy) {
// Initialize the principal, used only with AMSDK
// for proxy connections
adminPrincipal = new AuthPrincipal((String) AccessController.doPrivileged(new AdminDNAction()));
// Get UMS datalayer
dlayer = DataLayer.getInstance();
if (debug.messageEnabled()) {
debug.message("SMSLdapObject: DataLayer instance " + "obtained.");
}
} else {
// Get SM datalayer
smdlayer = SMDataLayer.getInstance();
if (debug.messageEnabled()) {
debug.message("SMSLdapObject: SMDataLayer instance " + "obtained.");
}
}
if ((dlayer == null) && (smdlayer == null)) {
debug.error("SMSLdapObject: Unable to initialize LDAP");
throw (new SMSException(IUMSConstants.UMS_BUNDLE_NAME, IUMSConstants.CONFIG_MGR_ERROR, null));
}
debug.message("SMSLdapObject: LDAP Initialized successfully");
// Get connection retry parameters
DataLayer.initConnectionParams();
connNumRetry = DataLayer.getConnNumRetry();
connRetryInterval = DataLayer.getConnRetryInterval();
retryErrorCodes = DataLayer.getRetryErrorCodes();
// Need to check if the root nodes exists. If not, create them
String serviceDN = SMSEntry.SERVICES_RDN + SMSEntry.COMMA + getRootSuffix();
if (!entryExists(serviceDN)) {
Map attrs = new HashMap();
Set attrValues = new HashSet();
attrValues.add(SMSEntry.OC_TOP);
attrValues.add(SMSEntry.OC_ORG_UNIT);
attrs.put(SMSEntry.ATTR_OBJECTCLASS, attrValues);
create(adminPrincipal, serviceDN, attrs);
}
} catch (Exception e) {
// Unable to initialize (trouble!!)
debug.error("SMSEntry: Unable to initalize(exception):", e);
throw (new SMSException(IUMSConstants.UMS_BUNDLE_NAME, IUMSConstants.CONFIG_MGR_ERROR, null));
}
initialized = true;
}
Aggregations