repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
alleveenstra/Mujina
mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/IssuerGenerator.java // public class IssuerGenerator { // // private final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // // // public IssuerGenerator(String issuingEntityName) { // super(); // this.issuingEntityName = issuingEntityName; // } // // // public Issuer generateIssuer() { // // Issuer // IssuerBuilder issuerBuilder = (IssuerBuilder) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME); // Issuer issuer = issuerBuilder.buildObject(); // // issuer.setValue(issuingEntityName); // issuer.setFormat(NameIDType.ENTITY); // // return issuer; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import org.opensaml.Configuration; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.core.impl.AuthnRequestBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import nl.surfnet.mujina.saml.xml.IssuerGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml; public class AuthnRequestGenerator { private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); private final String issuingEntityName;
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/IssuerGenerator.java // public class IssuerGenerator { // // private final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // // // public IssuerGenerator(String issuingEntityName) { // super(); // this.issuingEntityName = issuingEntityName; // } // // // public Issuer generateIssuer() { // // Issuer // IssuerBuilder issuerBuilder = (IssuerBuilder) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME); // Issuer issuer = issuerBuilder.buildObject(); // // issuer.setValue(issuingEntityName); // issuer.setFormat(NameIDType.ENTITY); // // return issuer; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java import org.opensaml.Configuration; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.core.impl.AuthnRequestBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import nl.surfnet.mujina.saml.xml.IssuerGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml; public class AuthnRequestGenerator { private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); private final String issuingEntityName;
private final TimeService timeService;
alleveenstra/Mujina
mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/IssuerGenerator.java // public class IssuerGenerator { // // private final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // // // public IssuerGenerator(String issuingEntityName) { // super(); // this.issuingEntityName = issuingEntityName; // } // // // public Issuer generateIssuer() { // // Issuer // IssuerBuilder issuerBuilder = (IssuerBuilder) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME); // Issuer issuer = issuerBuilder.buildObject(); // // issuer.setValue(issuingEntityName); // issuer.setFormat(NameIDType.ENTITY); // // return issuer; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import org.opensaml.Configuration; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.core.impl.AuthnRequestBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import nl.surfnet.mujina.saml.xml.IssuerGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml; public class AuthnRequestGenerator { private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); private final String issuingEntityName; private final TimeService timeService;
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/IssuerGenerator.java // public class IssuerGenerator { // // private final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // // // public IssuerGenerator(String issuingEntityName) { // super(); // this.issuingEntityName = issuingEntityName; // } // // // public Issuer generateIssuer() { // // Issuer // IssuerBuilder issuerBuilder = (IssuerBuilder) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME); // Issuer issuer = issuerBuilder.buildObject(); // // issuer.setValue(issuingEntityName); // issuer.setFormat(NameIDType.ENTITY); // // return issuer; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java import org.opensaml.Configuration; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.core.impl.AuthnRequestBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import nl.surfnet.mujina.saml.xml.IssuerGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml; public class AuthnRequestGenerator { private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); private final String issuingEntityName; private final TimeService timeService;
private final IDService idService;
alleveenstra/Mujina
mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/IssuerGenerator.java // public class IssuerGenerator { // // private final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // // // public IssuerGenerator(String issuingEntityName) { // super(); // this.issuingEntityName = issuingEntityName; // } // // // public Issuer generateIssuer() { // // Issuer // IssuerBuilder issuerBuilder = (IssuerBuilder) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME); // Issuer issuer = issuerBuilder.buildObject(); // // issuer.setValue(issuingEntityName); // issuer.setFormat(NameIDType.ENTITY); // // return issuer; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import org.opensaml.Configuration; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.core.impl.AuthnRequestBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import nl.surfnet.mujina.saml.xml.IssuerGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml; public class AuthnRequestGenerator { private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); private final String issuingEntityName; private final TimeService timeService; private final IDService idService;
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/IssuerGenerator.java // public class IssuerGenerator { // // private final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // // // public IssuerGenerator(String issuingEntityName) { // super(); // this.issuingEntityName = issuingEntityName; // } // // // public Issuer generateIssuer() { // // Issuer // IssuerBuilder issuerBuilder = (IssuerBuilder) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME); // Issuer issuer = issuerBuilder.buildObject(); // // issuer.setValue(issuingEntityName); // issuer.setFormat(NameIDType.ENTITY); // // return issuer; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java import org.opensaml.Configuration; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.core.impl.AuthnRequestBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import nl.surfnet.mujina.saml.xml.IssuerGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml; public class AuthnRequestGenerator { private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); private final String issuingEntityName; private final TimeService timeService; private final IDService idService;
private IssuerGenerator issuerGenerator;
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AuthnResponseGenerator.java
// Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Response; import org.opensaml.saml2.core.StatusCode; import org.opensaml.saml2.core.impl.ResponseBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.security.credential.Credential; import org.springframework.security.core.AuthenticationException; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AuthnResponseGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final String issuingEntityName; private final IssuerGenerator issuerGenerator; private final AssertionGenerator assertionGenerator;
// Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AuthnResponseGenerator.java import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Response; import org.opensaml.saml2.core.StatusCode; import org.opensaml.saml2.core.impl.ResponseBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.security.credential.Credential; import org.springframework.security.core.AuthenticationException; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AuthnResponseGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final String issuingEntityName; private final IssuerGenerator issuerGenerator; private final AssertionGenerator assertionGenerator;
private final IDService idService;
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AuthnResponseGenerator.java
// Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Response; import org.opensaml.saml2.core.StatusCode; import org.opensaml.saml2.core.impl.ResponseBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.security.credential.Credential; import org.springframework.security.core.AuthenticationException; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AuthnResponseGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final String issuingEntityName; private final IssuerGenerator issuerGenerator; private final AssertionGenerator assertionGenerator; private final IDService idService;
// Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AuthnResponseGenerator.java import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Response; import org.opensaml.saml2.core.StatusCode; import org.opensaml.saml2.core.impl.ResponseBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.security.credential.Credential; import org.springframework.security.core.AuthenticationException; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AuthnResponseGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final String issuingEntityName; private final IssuerGenerator issuerGenerator; private final AssertionGenerator assertionGenerator; private final IDService idService;
private final TimeService timeService;
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AuthnResponseGenerator.java
// Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Response; import org.opensaml.saml2.core.StatusCode; import org.opensaml.saml2.core.impl.ResponseBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.security.credential.Credential; import org.springframework.security.core.AuthenticationException; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AuthnResponseGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final String issuingEntityName; private final IssuerGenerator issuerGenerator; private final AssertionGenerator assertionGenerator; private final IDService idService; private final TimeService timeService; StatusGenerator statusGenerator;
// Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AuthnResponseGenerator.java import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Response; import org.opensaml.saml2.core.StatusCode; import org.opensaml.saml2.core.impl.ResponseBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.security.credential.Credential; import org.springframework.security.core.AuthenticationException; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AuthnResponseGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final String issuingEntityName; private final IssuerGenerator issuerGenerator; private final AssertionGenerator assertionGenerator; private final IDService idService; private final TimeService timeService; StatusGenerator statusGenerator;
public AuthnResponseGenerator(final Credential signingCredential, String issuingEntityName, TimeService timeService, IDService idService, IdpConfiguration idpConfiguration) {
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AuthnResponseGenerator.java
// Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Response; import org.opensaml.saml2.core.StatusCode; import org.opensaml.saml2.core.impl.ResponseBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.security.credential.Credential; import org.springframework.security.core.AuthenticationException; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AuthnResponseGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final String issuingEntityName; private final IssuerGenerator issuerGenerator; private final AssertionGenerator assertionGenerator; private final IDService idService; private final TimeService timeService; StatusGenerator statusGenerator; public AuthnResponseGenerator(final Credential signingCredential, String issuingEntityName, TimeService timeService, IDService idService, IdpConfiguration idpConfiguration) { super(); this.issuingEntityName = issuingEntityName; this.idService = idService; this.timeService = timeService; issuerGenerator = new IssuerGenerator(issuingEntityName); assertionGenerator = new AssertionGenerator(signingCredential, issuingEntityName, timeService, idService, idpConfiguration); statusGenerator = new StatusGenerator(); }
// Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AuthnResponseGenerator.java import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Response; import org.opensaml.saml2.core.StatusCode; import org.opensaml.saml2.core.impl.ResponseBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.security.credential.Credential; import org.springframework.security.core.AuthenticationException; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AuthnResponseGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final String issuingEntityName; private final IssuerGenerator issuerGenerator; private final AssertionGenerator assertionGenerator; private final IDService idService; private final TimeService timeService; StatusGenerator statusGenerator; public AuthnResponseGenerator(final Credential signingCredential, String issuingEntityName, TimeService timeService, IDService idService, IdpConfiguration idpConfiguration) { super(); this.issuingEntityName = issuingEntityName; this.idService = idService; this.timeService = timeService; issuerGenerator = new IssuerGenerator(issuingEntityName); assertionGenerator = new AssertionGenerator(signingCredential, issuingEntityName, timeService, idService, idpConfiguration); statusGenerator = new StatusGenerator(); }
public Response generateAuthnResponse(String remoteIP, SimpleAuthentication authToken, String recepientAssertionConsumerURL, int validForInSeconds, String inResponseTo, DateTime authnInstant) {
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/spring/security/CustomAuthenticationProvider.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // }
import nl.surfnet.mujina.model.SimpleAuthentication; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.GrantedAuthorityImpl; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring.security; public class CustomAuthenticationProvider implements AuthenticationProvider { @Autowired
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/spring/security/CustomAuthenticationProvider.java import nl.surfnet.mujina.model.SimpleAuthentication; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.GrantedAuthorityImpl; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring.security; public class CustomAuthenticationProvider implements AuthenticationProvider { @Autowired
private IdpConfiguration idpConfiguration;
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/spring/security/CustomAuthenticationProvider.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // }
import nl.surfnet.mujina.model.SimpleAuthentication; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.GrantedAuthorityImpl; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring.security; public class CustomAuthenticationProvider implements AuthenticationProvider { @Autowired private IdpConfiguration idpConfiguration; @Override public Authentication authenticate(final Authentication authentication) throws AuthenticationException { final String name = authentication.getName(); final String password = authentication.getCredentials().toString();
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/spring/security/CustomAuthenticationProvider.java import nl.surfnet.mujina.model.SimpleAuthentication; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.GrantedAuthorityImpl; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring.security; public class CustomAuthenticationProvider implements AuthenticationProvider { @Autowired private IdpConfiguration idpConfiguration; @Override public Authentication authenticate(final Authentication authentication) throws AuthenticationException { final String name = authentication.getName(); final String password = authentication.getCredentials().toString();
if (idpConfiguration.getAuthentication() == AuthenticationMethod.Method.ALL) {
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/spring/security/CustomAuthenticationProvider.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // }
import nl.surfnet.mujina.model.SimpleAuthentication; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.GrantedAuthorityImpl; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring.security; public class CustomAuthenticationProvider implements AuthenticationProvider { @Autowired private IdpConfiguration idpConfiguration; @Override public Authentication authenticate(final Authentication authentication) throws AuthenticationException { final String name = authentication.getName(); final String password = authentication.getCredentials().toString(); if (idpConfiguration.getAuthentication() == AuthenticationMethod.Method.ALL) { final List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); authorities.add(new GrantedAuthorityImpl("ROLE_USER"));
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/spring/security/CustomAuthenticationProvider.java import nl.surfnet.mujina.model.SimpleAuthentication; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.GrantedAuthorityImpl; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring.security; public class CustomAuthenticationProvider implements AuthenticationProvider { @Autowired private IdpConfiguration idpConfiguration; @Override public Authentication authenticate(final Authentication authentication) throws AuthenticationException { final String name = authentication.getName(); final String password = authentication.getCredentials().toString(); if (idpConfiguration.getAuthentication() == AuthenticationMethod.Method.ALL) { final List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); authorities.add(new GrantedAuthorityImpl("ROLE_USER"));
return new SimpleAuthentication(name, password, authorities);
alleveenstra/Mujina
mujina-common/src/main/java/nl/surfnet/mujina/controllers/CommonAPI.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/CommonConfiguration.java // public interface CommonConfiguration { // void reset(); // // KeyStore getKeyStore(); // // String getEntityID(); // // void setEntityID(String value); // // void injectCredential(String certificate, String key); // // Map<String, String> getPrivateKeyPasswords(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/Credential.java // @XmlRootElement // public class Credential implements Serializable { // private static final long serialVersionUID = 1L; // // private String certificate; // private String key; // // public String getCertificate() { // return certificate; // } // // @XmlElement // public void setCertificate(final String certificate) { // this.certificate = certificate; // } // // public String getKey() { // return key; // } // // @XmlElement // public void setKey(final String key) { // this.key = key; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/EntityID.java // @XmlRootElement // public class EntityID implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import nl.surfnet.mujina.model.CommonConfiguration; import nl.surfnet.mujina.model.Credential; import nl.surfnet.mujina.model.EntityID;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.controllers; @Controller public class CommonAPI { private final static Logger log = LoggerFactory.getLogger(CommonAPI.class);
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/CommonConfiguration.java // public interface CommonConfiguration { // void reset(); // // KeyStore getKeyStore(); // // String getEntityID(); // // void setEntityID(String value); // // void injectCredential(String certificate, String key); // // Map<String, String> getPrivateKeyPasswords(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/Credential.java // @XmlRootElement // public class Credential implements Serializable { // private static final long serialVersionUID = 1L; // // private String certificate; // private String key; // // public String getCertificate() { // return certificate; // } // // @XmlElement // public void setCertificate(final String certificate) { // this.certificate = certificate; // } // // public String getKey() { // return key; // } // // @XmlElement // public void setKey(final String key) { // this.key = key; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/EntityID.java // @XmlRootElement // public class EntityID implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // } // Path: mujina-common/src/main/java/nl/surfnet/mujina/controllers/CommonAPI.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import nl.surfnet.mujina.model.CommonConfiguration; import nl.surfnet.mujina.model.Credential; import nl.surfnet.mujina.model.EntityID; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.controllers; @Controller public class CommonAPI { private final static Logger log = LoggerFactory.getLogger(CommonAPI.class);
private CommonConfiguration configuration;
alleveenstra/Mujina
mujina-common/src/main/java/nl/surfnet/mujina/controllers/CommonAPI.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/CommonConfiguration.java // public interface CommonConfiguration { // void reset(); // // KeyStore getKeyStore(); // // String getEntityID(); // // void setEntityID(String value); // // void injectCredential(String certificate, String key); // // Map<String, String> getPrivateKeyPasswords(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/Credential.java // @XmlRootElement // public class Credential implements Serializable { // private static final long serialVersionUID = 1L; // // private String certificate; // private String key; // // public String getCertificate() { // return certificate; // } // // @XmlElement // public void setCertificate(final String certificate) { // this.certificate = certificate; // } // // public String getKey() { // return key; // } // // @XmlElement // public void setKey(final String key) { // this.key = key; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/EntityID.java // @XmlRootElement // public class EntityID implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import nl.surfnet.mujina.model.CommonConfiguration; import nl.surfnet.mujina.model.Credential; import nl.surfnet.mujina.model.EntityID;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.controllers; @Controller public class CommonAPI { private final static Logger log = LoggerFactory.getLogger(CommonAPI.class); private CommonConfiguration configuration; @Autowired public CommonAPI(final CommonConfiguration configuration) { this.configuration = configuration; } @RequestMapping(value = {"/reset"}, method = RequestMethod.POST) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody public void reset() { log.debug("Resetting to default configuration"); configuration.reset(); } @RequestMapping(value = {"/entityid"}, method = RequestMethod.PUT) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/CommonConfiguration.java // public interface CommonConfiguration { // void reset(); // // KeyStore getKeyStore(); // // String getEntityID(); // // void setEntityID(String value); // // void injectCredential(String certificate, String key); // // Map<String, String> getPrivateKeyPasswords(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/Credential.java // @XmlRootElement // public class Credential implements Serializable { // private static final long serialVersionUID = 1L; // // private String certificate; // private String key; // // public String getCertificate() { // return certificate; // } // // @XmlElement // public void setCertificate(final String certificate) { // this.certificate = certificate; // } // // public String getKey() { // return key; // } // // @XmlElement // public void setKey(final String key) { // this.key = key; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/EntityID.java // @XmlRootElement // public class EntityID implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // } // Path: mujina-common/src/main/java/nl/surfnet/mujina/controllers/CommonAPI.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import nl.surfnet.mujina.model.CommonConfiguration; import nl.surfnet.mujina.model.Credential; import nl.surfnet.mujina.model.EntityID; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.controllers; @Controller public class CommonAPI { private final static Logger log = LoggerFactory.getLogger(CommonAPI.class); private CommonConfiguration configuration; @Autowired public CommonAPI(final CommonConfiguration configuration) { this.configuration = configuration; } @RequestMapping(value = {"/reset"}, method = RequestMethod.POST) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody public void reset() { log.debug("Resetting to default configuration"); configuration.reset(); } @RequestMapping(value = {"/entityid"}, method = RequestMethod.PUT) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody
public void setEntityID(@RequestBody EntityID entityID) {
alleveenstra/Mujina
mujina-common/src/main/java/nl/surfnet/mujina/controllers/CommonAPI.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/CommonConfiguration.java // public interface CommonConfiguration { // void reset(); // // KeyStore getKeyStore(); // // String getEntityID(); // // void setEntityID(String value); // // void injectCredential(String certificate, String key); // // Map<String, String> getPrivateKeyPasswords(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/Credential.java // @XmlRootElement // public class Credential implements Serializable { // private static final long serialVersionUID = 1L; // // private String certificate; // private String key; // // public String getCertificate() { // return certificate; // } // // @XmlElement // public void setCertificate(final String certificate) { // this.certificate = certificate; // } // // public String getKey() { // return key; // } // // @XmlElement // public void setKey(final String key) { // this.key = key; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/EntityID.java // @XmlRootElement // public class EntityID implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import nl.surfnet.mujina.model.CommonConfiguration; import nl.surfnet.mujina.model.Credential; import nl.surfnet.mujina.model.EntityID;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.controllers; @Controller public class CommonAPI { private final static Logger log = LoggerFactory.getLogger(CommonAPI.class); private CommonConfiguration configuration; @Autowired public CommonAPI(final CommonConfiguration configuration) { this.configuration = configuration; } @RequestMapping(value = {"/reset"}, method = RequestMethod.POST) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody public void reset() { log.debug("Resetting to default configuration"); configuration.reset(); } @RequestMapping(value = {"/entityid"}, method = RequestMethod.PUT) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody public void setEntityID(@RequestBody EntityID entityID) { log.debug("Request to set entityID {}", entityID.getValue()); configuration.setEntityID(entityID.getValue()); } @RequestMapping(value = {"/signing-credential"}, method = RequestMethod.POST) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/CommonConfiguration.java // public interface CommonConfiguration { // void reset(); // // KeyStore getKeyStore(); // // String getEntityID(); // // void setEntityID(String value); // // void injectCredential(String certificate, String key); // // Map<String, String> getPrivateKeyPasswords(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/Credential.java // @XmlRootElement // public class Credential implements Serializable { // private static final long serialVersionUID = 1L; // // private String certificate; // private String key; // // public String getCertificate() { // return certificate; // } // // @XmlElement // public void setCertificate(final String certificate) { // this.certificate = certificate; // } // // public String getKey() { // return key; // } // // @XmlElement // public void setKey(final String key) { // this.key = key; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/model/EntityID.java // @XmlRootElement // public class EntityID implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // } // Path: mujina-common/src/main/java/nl/surfnet/mujina/controllers/CommonAPI.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import nl.surfnet.mujina.model.CommonConfiguration; import nl.surfnet.mujina.model.Credential; import nl.surfnet.mujina.model.EntityID; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.controllers; @Controller public class CommonAPI { private final static Logger log = LoggerFactory.getLogger(CommonAPI.class); private CommonConfiguration configuration; @Autowired public CommonAPI(final CommonConfiguration configuration) { this.configuration = configuration; } @RequestMapping(value = {"/reset"}, method = RequestMethod.POST) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody public void reset() { log.debug("Resetting to default configuration"); configuration.reset(); } @RequestMapping(value = {"/entityid"}, method = RequestMethod.PUT) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody public void setEntityID(@RequestBody EntityID entityID) { log.debug("Request to set entityID {}", entityID.getValue()); configuration.setEntityID(entityID.getValue()); } @RequestMapping(value = {"/signing-credential"}, method = RequestMethod.POST) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody
public void setSigningCredential(@RequestBody Credential credential) {
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/controllers/ApiSettings.java
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/oauth/AccessTokenRequestOption.java // public enum AccessTokenRequestOption { // // AUTHENTICATION_HEADER("Authentication Header"), QUERY_STRING_PARAMETERS("Query String Parameters"), ENTITY_BODY_PARAMETERS( // "Entity Body Parameters"); // // private String option; // // private AccessTokenRequestOption(String option) { // this.option = option; // } // // public String getOption() { // return option; // } // // public static AccessTokenRequestOption valueOfOption(String optionValue) { // AccessTokenRequestOption[] values = AccessTokenRequestOption.values(); // for (AccessTokenRequestOption option : values) { // if (option.getOption().equalsIgnoreCase(optionValue)) { // return option; // } // } // throw new RuntimeException( // String.format("Can't convert %s to an instance of AccessTokenRequestOption", optionValue)); // } // } // // Path: mujina-sp/src/main/java/nl/surfnet/mujina/oauth/OAuthVersion.java // public enum OAuthVersion { // // VERSION10A("1.0a"), VERSION20("2.0"); // // private String version; // // private OAuthVersion(String version) { // this.version = version; // } // // public String getVersion() { // return version; // } // // // // }
import nl.surfnet.mujina.oauth.AccessTokenRequestOption; import nl.surfnet.mujina.oauth.OAuthVersion; import org.scribe.model.Token;
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package nl.surfnet.mujina.controllers; /** * Backing form object for all Oauth calls from the Test Framework * */ public class ApiSettings { private String version = OAuthVersion.VERSION10A.getVersion();// "1.0a" private String requestTokenEndPoint; private String accessTokenEndPoint; private String accessTokenEndPoint2; private boolean twoLegged; private boolean implicitGrant; private String oauthKey; private String oauthSecret; private String authorizationURL; private String authorizationURL2; private String step; private Token requestToken; private boolean queryParameters;
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/oauth/AccessTokenRequestOption.java // public enum AccessTokenRequestOption { // // AUTHENTICATION_HEADER("Authentication Header"), QUERY_STRING_PARAMETERS("Query String Parameters"), ENTITY_BODY_PARAMETERS( // "Entity Body Parameters"); // // private String option; // // private AccessTokenRequestOption(String option) { // this.option = option; // } // // public String getOption() { // return option; // } // // public static AccessTokenRequestOption valueOfOption(String optionValue) { // AccessTokenRequestOption[] values = AccessTokenRequestOption.values(); // for (AccessTokenRequestOption option : values) { // if (option.getOption().equalsIgnoreCase(optionValue)) { // return option; // } // } // throw new RuntimeException( // String.format("Can't convert %s to an instance of AccessTokenRequestOption", optionValue)); // } // } // // Path: mujina-sp/src/main/java/nl/surfnet/mujina/oauth/OAuthVersion.java // public enum OAuthVersion { // // VERSION10A("1.0a"), VERSION20("2.0"); // // private String version; // // private OAuthVersion(String version) { // this.version = version; // } // // public String getVersion() { // return version; // } // // // // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/controllers/ApiSettings.java import nl.surfnet.mujina.oauth.AccessTokenRequestOption; import nl.surfnet.mujina.oauth.OAuthVersion; import org.scribe.model.Token; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package nl.surfnet.mujina.controllers; /** * Backing form object for all Oauth calls from the Test Framework * */ public class ApiSettings { private String version = OAuthVersion.VERSION10A.getVersion();// "1.0a" private String requestTokenEndPoint; private String accessTokenEndPoint; private String accessTokenEndPoint2; private boolean twoLegged; private boolean implicitGrant; private String oauthKey; private String oauthSecret; private String authorizationURL; private String authorizationURL2; private String step; private Token requestToken; private boolean queryParameters;
private String accessTokenRequestOption = AccessTokenRequestOption.ENTITY_BODY_PARAMETERS.getOption();// "Entity Body Parameters"
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLResponseAuthenticationProcessingFilter.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // }
import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; import nl.surfnet.mujina.saml.BindingAdapter; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.opensaml.common.binding.SAMLMessageContext; import org.opensaml.saml2.core.Response; import org.opensaml.ws.message.decoder.MessageDecodingException; import org.opensaml.xml.security.SecurityException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.Authentication;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLResponseAuthenticationProcessingFilter extends AbstractAuthenticationProcessingFilter { private final static Logger logger = LoggerFactory .getLogger(SAMLResponseAuthenticationProcessingFilter.class);
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLResponseAuthenticationProcessingFilter.java import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; import nl.surfnet.mujina.saml.BindingAdapter; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.opensaml.common.binding.SAMLMessageContext; import org.opensaml.saml2.core.Response; import org.opensaml.ws.message.decoder.MessageDecodingException; import org.opensaml.xml.security.SecurityException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.Authentication; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLResponseAuthenticationProcessingFilter extends AbstractAuthenticationProcessingFilter { private final static Logger logger = LoggerFactory .getLogger(SAMLResponseAuthenticationProcessingFilter.class);
private BindingAdapter bindingAdapter;
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AssertionGenerator.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.util.HashMap; import java.util.Map; import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.AuthnStatement; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.impl.AssertionBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.io.MarshallingException; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.SignatureConstants; import org.opensaml.xml.signature.SignatureException; import org.opensaml.xml.signature.Signer; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AssertionGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final IssuerGenerator issuerGenerator; private final SubjectGenerator subjectGenerator;
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AssertionGenerator.java import java.util.HashMap; import java.util.Map; import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.AuthnStatement; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.impl.AssertionBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.io.MarshallingException; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.SignatureConstants; import org.opensaml.xml.signature.SignatureException; import org.opensaml.xml.signature.Signer; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AssertionGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final IssuerGenerator issuerGenerator; private final SubjectGenerator subjectGenerator;
private final IDService idService;
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AssertionGenerator.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.util.HashMap; import java.util.Map; import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.AuthnStatement; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.impl.AssertionBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.io.MarshallingException; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.SignatureConstants; import org.opensaml.xml.signature.SignatureException; import org.opensaml.xml.signature.Signer; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AssertionGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final IssuerGenerator issuerGenerator; private final SubjectGenerator subjectGenerator; private final IDService idService;
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AssertionGenerator.java import java.util.HashMap; import java.util.Map; import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.AuthnStatement; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.impl.AssertionBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.io.MarshallingException; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.SignatureConstants; import org.opensaml.xml.signature.SignatureException; import org.opensaml.xml.signature.Signer; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AssertionGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final IssuerGenerator issuerGenerator; private final SubjectGenerator subjectGenerator; private final IDService idService;
private final TimeService timeService;
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AssertionGenerator.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.util.HashMap; import java.util.Map; import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.AuthnStatement; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.impl.AssertionBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.io.MarshallingException; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.SignatureConstants; import org.opensaml.xml.signature.SignatureException; import org.opensaml.xml.signature.Signer; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AssertionGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final IssuerGenerator issuerGenerator; private final SubjectGenerator subjectGenerator; private final IDService idService; private final TimeService timeService; private final AuthnStatementGenerator authnStatementGenerator = new AuthnStatementGenerator(); private final AttributeStatementGenerator attributeStatementGenerator = new AttributeStatementGenerator(); private Credential signingCredential;
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AssertionGenerator.java import java.util.HashMap; import java.util.Map; import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.AuthnStatement; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.impl.AssertionBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.io.MarshallingException; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.SignatureConstants; import org.opensaml.xml.signature.SignatureException; import org.opensaml.xml.signature.Signer; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AssertionGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final IssuerGenerator issuerGenerator; private final SubjectGenerator subjectGenerator; private final IDService idService; private final TimeService timeService; private final AuthnStatementGenerator authnStatementGenerator = new AuthnStatementGenerator(); private final AttributeStatementGenerator attributeStatementGenerator = new AttributeStatementGenerator(); private Credential signingCredential;
private IdpConfiguration idpConfiguration;
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AssertionGenerator.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.util.HashMap; import java.util.Map; import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.AuthnStatement; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.impl.AssertionBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.io.MarshallingException; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.SignatureConstants; import org.opensaml.xml.signature.SignatureException; import org.opensaml.xml.signature.Signer; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AssertionGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final IssuerGenerator issuerGenerator; private final SubjectGenerator subjectGenerator; private final IDService idService; private final TimeService timeService; private final AuthnStatementGenerator authnStatementGenerator = new AuthnStatementGenerator(); private final AttributeStatementGenerator attributeStatementGenerator = new AttributeStatementGenerator(); private Credential signingCredential; private IdpConfiguration idpConfiguration; public AssertionGenerator(final Credential signingCredential, String issuingEntityName, TimeService timeService, IDService idService, IdpConfiguration idpConfiguration) { super(); this.signingCredential = signingCredential; this.timeService = timeService; this.idService = idService; this.idpConfiguration = idpConfiguration; issuerGenerator = new IssuerGenerator(issuingEntityName); subjectGenerator = new SubjectGenerator(timeService); }
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AssertionGenerator.java import java.util.HashMap; import java.util.Map; import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.AuthnStatement; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.impl.AssertionBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.io.MarshallingException; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.SignatureConstants; import org.opensaml.xml.signature.SignatureException; import org.opensaml.xml.signature.Signer; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class AssertionGenerator { private final XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); private final IssuerGenerator issuerGenerator; private final SubjectGenerator subjectGenerator; private final IDService idService; private final TimeService timeService; private final AuthnStatementGenerator authnStatementGenerator = new AuthnStatementGenerator(); private final AttributeStatementGenerator attributeStatementGenerator = new AttributeStatementGenerator(); private Credential signingCredential; private IdpConfiguration idpConfiguration; public AssertionGenerator(final Credential signingCredential, String issuingEntityName, TimeService timeService, IDService idService, IdpConfiguration idpConfiguration) { super(); this.signingCredential = signingCredential; this.timeService = timeService; this.idService = idService; this.idpConfiguration = idpConfiguration; issuerGenerator = new IssuerGenerator(issuingEntityName); subjectGenerator = new SubjectGenerator(timeService); }
public Assertion generateAssertion(String remoteIP, SimpleAuthentication authToken, String recepientAssertionConsumerURL, int validForInSeconds, String inResponseTo, DateTime authnInstant) {
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AssertionGenerator.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.util.HashMap; import java.util.Map; import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.AuthnStatement; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.impl.AssertionBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.io.MarshallingException; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.SignatureConstants; import org.opensaml.xml.signature.SignatureException; import org.opensaml.xml.signature.Signer; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
this.idService = idService; this.idpConfiguration = idpConfiguration; issuerGenerator = new IssuerGenerator(issuingEntityName); subjectGenerator = new SubjectGenerator(timeService); } public Assertion generateAssertion(String remoteIP, SimpleAuthentication authToken, String recepientAssertionConsumerURL, int validForInSeconds, String inResponseTo, DateTime authnInstant) { // org.apache.xml.security.utils.ElementProxy.setDefaultPrefix(namespaceURI, prefix). AssertionBuilder assertionBuilder = (AssertionBuilder) builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME); Assertion assertion = assertionBuilder.buildObject(); Subject subject = subjectGenerator.generateSubject(recepientAssertionConsumerURL, validForInSeconds, authToken.getName(), inResponseTo, remoteIP); Issuer issuer = issuerGenerator.generateIssuer(); AuthnStatement authnStatement = authnStatementGenerator.generateAuthnStatement(authnInstant); assertion.setIssuer(issuer); assertion.getAuthnStatements().add(authnStatement); assertion.setSubject(subject); // extends this // assertion.getAttributeStatements().add(attributeStatementGenerator.generateAttributeStatement(authToken.getAuthorities())); final Map<String,String> attributes = new HashMap<String, String>(); attributes.putAll(idpConfiguration.getAttributes());
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/AuthenticationMethod.java // @XmlRootElement // public class AuthenticationMethod implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // public enum Method { // USER, ALL // } // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/IdpConfiguration.java // public interface IdpConfiguration extends CommonConfiguration { // Map<String, String> getAttributes(); // // Collection<SimpleAuthentication> getUsers(); // // AuthenticationMethod.Method getAuthentication(); // // void setAuthentication(AuthenticationMethod.Method method); // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/model/SimpleAuthentication.java // public class SimpleAuthentication implements Authentication { // // private String username; // private String password; // private Collection<GrantedAuthority> authorities; // // // public SimpleAuthentication(String username, // String password, // Collection<GrantedAuthority> authorities) { // this.username = username; // this.password = password; // this.authorities = authorities; // } // // @Override // public Collection<GrantedAuthority> getAuthorities() { // return authorities; // } // // @Override // public Object getCredentials() { // return password; // } // // @Override // public Object getDetails() { // return null; // } // // @Override // public Object getPrincipal() { // return username; // } // // @Override // public boolean isAuthenticated() { // return true; // } // // @Override // public void setAuthenticated(final boolean isAuthenticated) throws IllegalArgumentException { // } // // @Override // public String toString() { // return username + " / " + password; // } // // @Override // public String getName() { // return username; // } // // @Override // public boolean equals(final Object o) { // if (this == o) { // return true; // } // if (o == null || getClass() != o.getClass()) { // return false; // } // // final SimpleAuthentication that = (SimpleAuthentication) o; // // if (authorities != null ? !authorities.equals(that.authorities) : that.authorities != null) { // return false; // } // if (password != null ? !password.equals(that.password) : that.password != null) { // return false; // } // if (username != null ? !username.equals(that.username) : that.username != null) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result = username != null ? username.hashCode() : 0; // result = 31 * result + (password != null ? password.hashCode() : 0); // result = 31 * result + (authorities != null ? authorities.hashCode() : 0); // return result; // } // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/AssertionGenerator.java import java.util.HashMap; import java.util.Map; import org.joda.time.DateTime; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.AuthnStatement; import org.opensaml.saml2.core.Issuer; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.impl.AssertionBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import org.opensaml.xml.io.MarshallingException; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.signature.Signature; import org.opensaml.xml.signature.SignatureConstants; import org.opensaml.xml.signature.SignatureException; import org.opensaml.xml.signature.Signer; import nl.surfnet.mujina.model.AuthenticationMethod; import nl.surfnet.mujina.model.IdpConfiguration; import nl.surfnet.mujina.model.SimpleAuthentication; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; this.idService = idService; this.idpConfiguration = idpConfiguration; issuerGenerator = new IssuerGenerator(issuingEntityName); subjectGenerator = new SubjectGenerator(timeService); } public Assertion generateAssertion(String remoteIP, SimpleAuthentication authToken, String recepientAssertionConsumerURL, int validForInSeconds, String inResponseTo, DateTime authnInstant) { // org.apache.xml.security.utils.ElementProxy.setDefaultPrefix(namespaceURI, prefix). AssertionBuilder assertionBuilder = (AssertionBuilder) builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME); Assertion assertion = assertionBuilder.buildObject(); Subject subject = subjectGenerator.generateSubject(recepientAssertionConsumerURL, validForInSeconds, authToken.getName(), inResponseTo, remoteIP); Issuer issuer = issuerGenerator.generateIssuer(); AuthnStatement authnStatement = authnStatementGenerator.generateAuthnStatement(authnInstant); assertion.setIssuer(issuer); assertion.getAuthnStatements().add(authnStatement); assertion.setSubject(subject); // extends this // assertion.getAttributeStatements().add(attributeStatementGenerator.generateAttributeStatement(authToken.getAuthorities())); final Map<String,String> attributes = new HashMap<String, String>(); attributes.putAll(idpConfiguration.getAttributes());
if (idpConfiguration.getAuthentication() == AuthenticationMethod.Method.ALL) {
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/controllers/ServiceProviderAPI.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/SSOServiceURL.java // @XmlRootElement // public class SSOServiceURL implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // } // // Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import nl.surfnet.mujina.model.SSOServiceURL; import nl.surfnet.mujina.model.SpConfiguration;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.controllers; @Controller public class ServiceProviderAPI { private final static Logger log = LoggerFactory .getLogger(ServiceProviderAPI.class);
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/SSOServiceURL.java // @XmlRootElement // public class SSOServiceURL implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // } // // Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/controllers/ServiceProviderAPI.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import nl.surfnet.mujina.model.SSOServiceURL; import nl.surfnet.mujina.model.SpConfiguration; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.controllers; @Controller public class ServiceProviderAPI { private final static Logger log = LoggerFactory .getLogger(ServiceProviderAPI.class);
final SpConfiguration configuration;
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/controllers/ServiceProviderAPI.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/SSOServiceURL.java // @XmlRootElement // public class SSOServiceURL implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // } // // Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import nl.surfnet.mujina.model.SSOServiceURL; import nl.surfnet.mujina.model.SpConfiguration;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.controllers; @Controller public class ServiceProviderAPI { private final static Logger log = LoggerFactory .getLogger(ServiceProviderAPI.class); final SpConfiguration configuration; @Autowired public ServiceProviderAPI(final SpConfiguration configuration) { this.configuration = configuration; } @RequestMapping(value = {"/ssoServiceURL"}, method = RequestMethod.PUT) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody
// Path: mujina-common/src/main/java/nl/surfnet/mujina/model/SSOServiceURL.java // @XmlRootElement // public class SSOServiceURL implements Serializable { // private static final long serialVersionUID = 1L; // // private String value; // // public String getValue() { // return value; // } // // @XmlElement // public void setValue(final String value) { // this.value = value; // } // // } // // Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/controllers/ServiceProviderAPI.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; import nl.surfnet.mujina.model.SSOServiceURL; import nl.surfnet.mujina.model.SpConfiguration; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.controllers; @Controller public class ServiceProviderAPI { private final static Logger log = LoggerFactory .getLogger(ServiceProviderAPI.class); final SpConfiguration configuration; @Autowired public ServiceProviderAPI(final SpConfiguration configuration) { this.configuration = configuration; } @RequestMapping(value = {"/ssoServiceURL"}, method = RequestMethod.PUT) @ResponseStatus(HttpStatus.NO_CONTENT) @ResponseBody
public void setAttribute(@RequestBody SSOServiceURL ssoServiceURL) {
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/SingleSignOnService.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/SAML2ValidatorSuite.java // public class SAML2ValidatorSuite { // // public void validate(XMLObject xmlObject) throws ValidationException { // // ValidatorSuite schemaValidator = Configuration.getValidatorSuite("saml2-core-schema-validator"); // schemaValidator.validate(xmlObject); // ValidatorSuite specValidator = Configuration.getValidatorSuite("saml2-core-spec-validator"); // specValidator.validate(xmlObject); // // } // // // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/spring/AuthnRequestInfo.java // public class AuthnRequestInfo implements Serializable { // // private final String assertionConumerURL; // private final String authnRequestID; // // public AuthnRequestInfo(String assertionConumerURL, String authnRequestID) { // super(); // this.assertionConumerURL = assertionConumerURL; // this.authnRequestID = authnRequestID; // } // // public String getAssertionConumerURL() { // return assertionConumerURL; // } // // // public String getAuthnRequestID() { // return authnRequestID; // } // // @Override // public String toString() { // return new ToStringBuilder(this). // append("assertionConumerURL", assertionConumerURL). // append("authnRequestID", authnRequestID). // toString(); // // // } // // // }
import org.springframework.web.HttpRequestHandler; import nl.surfnet.mujina.saml.xml.SAML2ValidatorSuite; import nl.surfnet.mujina.spring.AuthnRequestInfo; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.opensaml.common.binding.SAMLMessageContext; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.ws.message.decoder.MessageDecodingException; import org.opensaml.xml.security.SecurityException; import org.opensaml.xml.validation.ValidationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.web.WebAttributes;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml; public class SingleSignOnService implements HttpRequestHandler { private final static Logger logger = LoggerFactory .getLogger(SingleSignOnService.class); private final BindingAdapter adapter; private final String authnResponderURI;
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/SAML2ValidatorSuite.java // public class SAML2ValidatorSuite { // // public void validate(XMLObject xmlObject) throws ValidationException { // // ValidatorSuite schemaValidator = Configuration.getValidatorSuite("saml2-core-schema-validator"); // schemaValidator.validate(xmlObject); // ValidatorSuite specValidator = Configuration.getValidatorSuite("saml2-core-spec-validator"); // specValidator.validate(xmlObject); // // } // // // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/spring/AuthnRequestInfo.java // public class AuthnRequestInfo implements Serializable { // // private final String assertionConumerURL; // private final String authnRequestID; // // public AuthnRequestInfo(String assertionConumerURL, String authnRequestID) { // super(); // this.assertionConumerURL = assertionConumerURL; // this.authnRequestID = authnRequestID; // } // // public String getAssertionConumerURL() { // return assertionConumerURL; // } // // // public String getAuthnRequestID() { // return authnRequestID; // } // // @Override // public String toString() { // return new ToStringBuilder(this). // append("assertionConumerURL", assertionConumerURL). // append("authnRequestID", authnRequestID). // toString(); // // // } // // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/SingleSignOnService.java import org.springframework.web.HttpRequestHandler; import nl.surfnet.mujina.saml.xml.SAML2ValidatorSuite; import nl.surfnet.mujina.spring.AuthnRequestInfo; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.opensaml.common.binding.SAMLMessageContext; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.ws.message.decoder.MessageDecodingException; import org.opensaml.xml.security.SecurityException; import org.opensaml.xml.validation.ValidationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.web.WebAttributes; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml; public class SingleSignOnService implements HttpRequestHandler { private final static Logger logger = LoggerFactory .getLogger(SingleSignOnService.class); private final BindingAdapter adapter; private final String authnResponderURI;
private final SAML2ValidatorSuite validatorSuite;
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/SingleSignOnService.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/SAML2ValidatorSuite.java // public class SAML2ValidatorSuite { // // public void validate(XMLObject xmlObject) throws ValidationException { // // ValidatorSuite schemaValidator = Configuration.getValidatorSuite("saml2-core-schema-validator"); // schemaValidator.validate(xmlObject); // ValidatorSuite specValidator = Configuration.getValidatorSuite("saml2-core-spec-validator"); // specValidator.validate(xmlObject); // // } // // // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/spring/AuthnRequestInfo.java // public class AuthnRequestInfo implements Serializable { // // private final String assertionConumerURL; // private final String authnRequestID; // // public AuthnRequestInfo(String assertionConumerURL, String authnRequestID) { // super(); // this.assertionConumerURL = assertionConumerURL; // this.authnRequestID = authnRequestID; // } // // public String getAssertionConumerURL() { // return assertionConumerURL; // } // // // public String getAuthnRequestID() { // return authnRequestID; // } // // @Override // public String toString() { // return new ToStringBuilder(this). // append("assertionConumerURL", assertionConumerURL). // append("authnRequestID", authnRequestID). // toString(); // // // } // // // }
import org.springframework.web.HttpRequestHandler; import nl.surfnet.mujina.saml.xml.SAML2ValidatorSuite; import nl.surfnet.mujina.spring.AuthnRequestInfo; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.opensaml.common.binding.SAMLMessageContext; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.ws.message.decoder.MessageDecodingException; import org.opensaml.xml.security.SecurityException; import org.opensaml.xml.validation.ValidationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.web.WebAttributes;
this.validatorSuite = validatorSuite; } @Override public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { SAMLMessageContext messageContext = null; try { messageContext = adapter.extractSAMLMessageContext(request); } catch (MessageDecodingException mde) { logger.error("Exception decoding SAML message", mde); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } catch (SecurityException se) { logger.error("Exception decoding SAML message", se); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } AuthnRequest authnRequest = (AuthnRequest) messageContext.getInboundSAMLMessage(); try { validatorSuite.validate(authnRequest); } catch (ValidationException ve) { logger.warn("AuthnRequest Message failed Validation", ve); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; }
// Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/SAML2ValidatorSuite.java // public class SAML2ValidatorSuite { // // public void validate(XMLObject xmlObject) throws ValidationException { // // ValidatorSuite schemaValidator = Configuration.getValidatorSuite("saml2-core-schema-validator"); // schemaValidator.validate(xmlObject); // ValidatorSuite specValidator = Configuration.getValidatorSuite("saml2-core-spec-validator"); // specValidator.validate(xmlObject); // // } // // // } // // Path: mujina-idp/src/main/java/nl/surfnet/mujina/spring/AuthnRequestInfo.java // public class AuthnRequestInfo implements Serializable { // // private final String assertionConumerURL; // private final String authnRequestID; // // public AuthnRequestInfo(String assertionConumerURL, String authnRequestID) { // super(); // this.assertionConumerURL = assertionConumerURL; // this.authnRequestID = authnRequestID; // } // // public String getAssertionConumerURL() { // return assertionConumerURL; // } // // // public String getAuthnRequestID() { // return authnRequestID; // } // // @Override // public String toString() { // return new ToStringBuilder(this). // append("assertionConumerURL", assertionConumerURL). // append("authnRequestID", authnRequestID). // toString(); // // // } // // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/SingleSignOnService.java import org.springframework.web.HttpRequestHandler; import nl.surfnet.mujina.saml.xml.SAML2ValidatorSuite; import nl.surfnet.mujina.spring.AuthnRequestInfo; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.opensaml.common.binding.SAMLMessageContext; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.ws.message.decoder.MessageDecodingException; import org.opensaml.xml.security.SecurityException; import org.opensaml.xml.validation.ValidationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.web.WebAttributes; this.validatorSuite = validatorSuite; } @Override public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { SAMLMessageContext messageContext = null; try { messageContext = adapter.extractSAMLMessageContext(request); } catch (MessageDecodingException mde) { logger.error("Exception decoding SAML message", mde); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } catch (SecurityException se) { logger.error("Exception decoding SAML message", se); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } AuthnRequest authnRequest = (AuthnRequest) messageContext.getInboundSAMLMessage(); try { validatorSuite.validate(authnRequest); } catch (ValidationException ve) { logger.warn("AuthnRequest Message failed Validation", ve); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; }
AuthnRequestInfo info = new AuthnRequestInfo(authnRequest.getAssertionConsumerServiceURL(), authnRequest.getID());
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class);
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class);
private final TimeService timeService;
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class); private final TimeService timeService;
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class); private final TimeService timeService;
private final IDService idService;
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class); private final TimeService timeService; private final IDService idService; private String assertionConsumerServiceURL;
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class); private final TimeService timeService; private final IDService idService; private String assertionConsumerServiceURL;
private BindingAdapter bindingAdapter;
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class); private final TimeService timeService; private final IDService idService; private String assertionConsumerServiceURL; private BindingAdapter bindingAdapter; private CredentialResolver credentialResolver;
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class); private final TimeService timeService; private final IDService idService; private String assertionConsumerServiceURL; private BindingAdapter bindingAdapter; private CredentialResolver credentialResolver;
private SpConfiguration spConfiguration;
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
super(); this.timeService = timeService; this.idService = idService; } @Required public void setAssertionConsumerServiceURL(String assertionConsumerServiceURL) { this.assertionConsumerServiceURL = assertionConsumerServiceURL; } @Required public void setBindingAdapter(BindingAdapter bindingAdapter) { this.bindingAdapter = bindingAdapter; } @Required public void setCredentialResolver(CredentialResolver credentialResolver) { this.credentialResolver = credentialResolver; } public void setConfiguration(final SpConfiguration spConfiguration) { this.spConfiguration = spConfiguration; } @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; super(); this.timeService = timeService; this.idService = idService; } @Required public void setAssertionConsumerServiceURL(String assertionConsumerServiceURL) { this.assertionConsumerServiceURL = assertionConsumerServiceURL; } @Required public void setBindingAdapter(BindingAdapter bindingAdapter) { this.bindingAdapter = bindingAdapter; } @Required public void setCredentialResolver(CredentialResolver credentialResolver) { this.credentialResolver = credentialResolver; } public void setConfiguration(final SpConfiguration spConfiguration) { this.spConfiguration = spConfiguration; } @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
AuthnRequestGenerator authnRequestGenerator = new AuthnRequestGenerator(spConfiguration.getEntityID(), timeService, idService);
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService;
this.timeService = timeService; this.idService = idService; } @Required public void setAssertionConsumerServiceURL(String assertionConsumerServiceURL) { this.assertionConsumerServiceURL = assertionConsumerServiceURL; } @Required public void setBindingAdapter(BindingAdapter bindingAdapter) { this.bindingAdapter = bindingAdapter; } @Required public void setCredentialResolver(CredentialResolver credentialResolver) { this.credentialResolver = credentialResolver; } public void setConfiguration(final SpConfiguration spConfiguration) { this.spConfiguration = spConfiguration; } @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { AuthnRequestGenerator authnRequestGenerator = new AuthnRequestGenerator(spConfiguration.getEntityID(), timeService, idService);
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/AuthnRequestGenerator.java // public class AuthnRequestGenerator { // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // private final String issuingEntityName; // private final TimeService timeService; // private final IDService idService; // private IssuerGenerator issuerGenerator; // // public AuthnRequestGenerator(String issuingEntityName, TimeService timeService, IDService idService) { // super(); // this.issuingEntityName = issuingEntityName; // this.timeService = timeService; // this.idService = idService; // // issuerGenerator = new IssuerGenerator(issuingEntityName); // } // // public AuthnRequest generateAuthnRequest(String destination, String responseLocation) { // // AuthnRequestBuilder authnRequestBuilder = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); // // AuthnRequest authnRequest = authnRequestBuilder.buildObject(); // // authnRequest.setAssertionConsumerServiceURL(responseLocation); // authnRequest.setID(idService.generateID()); // authnRequest.setIssueInstant(timeService.getCurrentDateTime()); // authnRequest.setDestination(destination); // // authnRequest.setIssuer(issuerGenerator.generateIssuer()); // // return authnRequest; // } // // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/BindingAdapter.java // public interface BindingAdapter { // // public void sendSAMLMessage(SignableSAMLObject samlMessage, Endpoint endpoint, Credential signingCredential, HttpServletResponse response) throws MessageEncodingException; // // public SAMLMessageContext extractSAMLMessageContext(HttpServletRequest request) throws MessageDecodingException, SecurityException; // // public String extractSAMLMessage(HttpServletRequest request); // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/saml/xml/EndpointGenerator.java // public class EndpointGenerator { // // private final static Logger logger = LoggerFactory.getLogger(EndpointGenerator.class); // // private XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory(); // // public Endpoint generateEndpoint(QName service, String location, String responseLocation) { // // logger.debug("end point service: {}", service); // logger.debug("end point location: {}", location); // logger.debug("end point responseLocation: {}", responseLocation); // // SAMLObjectBuilder<Endpoint> endpointBuilder = (SAMLObjectBuilder<Endpoint>) builderFactory.getBuilder(service); // Endpoint samlEndpoint = endpointBuilder.buildObject(); // // samlEndpoint.setLocation(location); // // // this does not have to be set // if (StringUtils.isNotEmpty(responseLocation)) // samlEndpoint.setResponseLocation(responseLocation); // // return samlEndpoint; // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/IDService.java // public class IDService { // // public String generateID() { // return UUID.randomUUID().toString(); // } // // } // // Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.Validate; import org.opensaml.saml2.core.AuthnRequest; import org.opensaml.saml2.metadata.Endpoint; import org.opensaml.saml2.metadata.SingleSignOnService; import org.opensaml.ws.message.encoder.MessageEncodingException; import org.opensaml.xml.security.*; import org.opensaml.xml.security.credential.Credential; import org.opensaml.xml.security.credential.CredentialResolver; import org.opensaml.xml.security.credential.UsageType; import org.opensaml.xml.security.criteria.EntityIDCriteria; import org.opensaml.xml.security.criteria.UsageCriteria; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.saml.AuthnRequestGenerator; import nl.surfnet.mujina.saml.BindingAdapter; import nl.surfnet.mujina.saml.xml.EndpointGenerator; import nl.surfnet.mujina.util.IDService; import nl.surfnet.mujina.util.TimeService; this.timeService = timeService; this.idService = idService; } @Required public void setAssertionConsumerServiceURL(String assertionConsumerServiceURL) { this.assertionConsumerServiceURL = assertionConsumerServiceURL; } @Required public void setBindingAdapter(BindingAdapter bindingAdapter) { this.bindingAdapter = bindingAdapter; } @Required public void setCredentialResolver(CredentialResolver credentialResolver) { this.credentialResolver = credentialResolver; } public void setConfiguration(final SpConfiguration spConfiguration) { this.spConfiguration = spConfiguration; } @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { AuthnRequestGenerator authnRequestGenerator = new AuthnRequestGenerator(spConfiguration.getEntityID(), timeService, idService);
EndpointGenerator endpointGenerator = new EndpointGenerator();
alleveenstra/Mujina
mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLResponseAuthenticationProvider.java
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/saml/AssertionConsumer.java // public interface AssertionConsumer { // // User consume(Response samlResponse) throws AuthenticationException; // // }
import org.opensaml.saml2.core.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import nl.surfnet.mujina.saml.AssertionConsumer;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLResponseAuthenticationProvider implements AuthenticationProvider { private final static Logger logger = LoggerFactory .getLogger(SAMLResponseAuthenticationProvider.class);
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/saml/AssertionConsumer.java // public interface AssertionConsumer { // // User consume(Response samlResponse) throws AuthenticationException; // // } // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLResponseAuthenticationProvider.java import org.opensaml.saml2.core.Response; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import nl.surfnet.mujina.saml.AssertionConsumer; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.spring; public class SAMLResponseAuthenticationProvider implements AuthenticationProvider { private final static Logger logger = LoggerFactory .getLogger(SAMLResponseAuthenticationProvider.class);
private final AssertionConsumer assertionConsumer;
alleveenstra/Mujina
mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/SubjectGenerator.java
// Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // }
import org.opensaml.Configuration; import org.opensaml.saml2.core.NameID; import org.opensaml.saml2.core.NameIDType; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.SubjectConfirmation; import org.opensaml.saml2.core.SubjectConfirmationData; import org.opensaml.saml2.core.impl.NameIDBuilder; import org.opensaml.saml2.core.impl.SubjectBuilder; import org.opensaml.saml2.core.impl.SubjectConfirmationBuilder; import org.opensaml.saml2.core.impl.SubjectConfirmationDataBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import nl.surfnet.mujina.util.TimeService;
/* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class SubjectGenerator { private final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
// Path: mujina-common/src/main/java/nl/surfnet/mujina/util/TimeService.java // public class TimeService { // // public DateTime getCurrentDateTime() { // return new DateTime(); // } // // } // Path: mujina-idp/src/main/java/nl/surfnet/mujina/saml/xml/SubjectGenerator.java import org.opensaml.Configuration; import org.opensaml.saml2.core.NameID; import org.opensaml.saml2.core.NameIDType; import org.opensaml.saml2.core.Subject; import org.opensaml.saml2.core.SubjectConfirmation; import org.opensaml.saml2.core.SubjectConfirmationData; import org.opensaml.saml2.core.impl.NameIDBuilder; import org.opensaml.saml2.core.impl.SubjectBuilder; import org.opensaml.saml2.core.impl.SubjectConfirmationBuilder; import org.opensaml.saml2.core.impl.SubjectConfirmationDataBuilder; import org.opensaml.xml.XMLObjectBuilderFactory; import nl.surfnet.mujina.util.TimeService; /* * Copyright 2012 SURFnet bv, The Netherlands * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package nl.surfnet.mujina.saml.xml; public class SubjectGenerator { private final XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
private final TimeService timeService;
alleveenstra/Mujina
mujina-sp/src/test/java/nl/surfnet/mujina/controllers/tests/SpRestAPITest.java
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java // public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { // // private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class); // // private final TimeService timeService; // private final IDService idService; // // private String assertionConsumerServiceURL; // private BindingAdapter bindingAdapter; // private CredentialResolver credentialResolver; // // private SpConfiguration spConfiguration; // // public SAMLAuthenticationEntryPoint(TimeService timeService, IDService idService) { // super(); // this.timeService = timeService; // this.idService = idService; // } // // @Required // public void setAssertionConsumerServiceURL(String assertionConsumerServiceURL) { // this.assertionConsumerServiceURL = assertionConsumerServiceURL; // } // // @Required // public void setBindingAdapter(BindingAdapter bindingAdapter) { // this.bindingAdapter = bindingAdapter; // } // // // @Required // public void setCredentialResolver(CredentialResolver credentialResolver) { // this.credentialResolver = credentialResolver; // } // // public void setConfiguration(final SpConfiguration spConfiguration) { // this.spConfiguration = spConfiguration; // } // // @Override // public void commence(HttpServletRequest request, // HttpServletResponse response, // AuthenticationException authException) throws IOException, ServletException { // // AuthnRequestGenerator authnRequestGenerator = new AuthnRequestGenerator(spConfiguration.getEntityID(), timeService, idService); // EndpointGenerator endpointGenerator = new EndpointGenerator(); // // final String singleSignOnServiceURL = spConfiguration.getSingleSignOnServiceURL(); // // Endpoint endpoint = endpointGenerator.generateEndpoint(SingleSignOnService.DEFAULT_ELEMENT_NAME, singleSignOnServiceURL, assertionConsumerServiceURL); // // AuthnRequest authnReqeust = authnRequestGenerator.generateAuthnRequest(singleSignOnServiceURL, assertionConsumerServiceURL); // // log.debug("Sending authnRequest to {}", singleSignOnServiceURL); // // try { // CriteriaSet criteriaSet = new CriteriaSet(); // criteriaSet.add(new EntityIDCriteria(spConfiguration.getEntityID())); // criteriaSet.add(new UsageCriteria(UsageType.SIGNING)); // // Credential signingCredential = credentialResolver.resolveSingle(criteriaSet); // Validate.notNull(signingCredential); // // bindingAdapter.sendSAMLMessage(authnReqeust, endpoint, signingCredential, response); // } catch (MessageEncodingException mee) { // log.error("Could not send authnRequest to Identity Provider.", mee); // response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // } catch (org.opensaml.xml.security.SecurityException e) { // log.error("Unable to retrieve signing credential", e); // response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // } // } // }
import java.io.IOException; import javax.servlet.ServletException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.spring.SAMLAuthenticationEntryPoint; import static junit.framework.Assert.assertTrue;
package nl.surfnet.mujina.controllers.tests; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext-sp-config.xml", "classpath:applicationContext-property-mappings.xml", "classpath:applicationContext-spring-security.xml", "classpath:api-servlet.xml"}) public class SpRestAPITest { public static final String SIGN_ON_SERVICE_URL = "http://www.test.nl/"; @Autowired
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java // public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { // // private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class); // // private final TimeService timeService; // private final IDService idService; // // private String assertionConsumerServiceURL; // private BindingAdapter bindingAdapter; // private CredentialResolver credentialResolver; // // private SpConfiguration spConfiguration; // // public SAMLAuthenticationEntryPoint(TimeService timeService, IDService idService) { // super(); // this.timeService = timeService; // this.idService = idService; // } // // @Required // public void setAssertionConsumerServiceURL(String assertionConsumerServiceURL) { // this.assertionConsumerServiceURL = assertionConsumerServiceURL; // } // // @Required // public void setBindingAdapter(BindingAdapter bindingAdapter) { // this.bindingAdapter = bindingAdapter; // } // // // @Required // public void setCredentialResolver(CredentialResolver credentialResolver) { // this.credentialResolver = credentialResolver; // } // // public void setConfiguration(final SpConfiguration spConfiguration) { // this.spConfiguration = spConfiguration; // } // // @Override // public void commence(HttpServletRequest request, // HttpServletResponse response, // AuthenticationException authException) throws IOException, ServletException { // // AuthnRequestGenerator authnRequestGenerator = new AuthnRequestGenerator(spConfiguration.getEntityID(), timeService, idService); // EndpointGenerator endpointGenerator = new EndpointGenerator(); // // final String singleSignOnServiceURL = spConfiguration.getSingleSignOnServiceURL(); // // Endpoint endpoint = endpointGenerator.generateEndpoint(SingleSignOnService.DEFAULT_ELEMENT_NAME, singleSignOnServiceURL, assertionConsumerServiceURL); // // AuthnRequest authnReqeust = authnRequestGenerator.generateAuthnRequest(singleSignOnServiceURL, assertionConsumerServiceURL); // // log.debug("Sending authnRequest to {}", singleSignOnServiceURL); // // try { // CriteriaSet criteriaSet = new CriteriaSet(); // criteriaSet.add(new EntityIDCriteria(spConfiguration.getEntityID())); // criteriaSet.add(new UsageCriteria(UsageType.SIGNING)); // // Credential signingCredential = credentialResolver.resolveSingle(criteriaSet); // Validate.notNull(signingCredential); // // bindingAdapter.sendSAMLMessage(authnReqeust, endpoint, signingCredential, response); // } catch (MessageEncodingException mee) { // log.error("Could not send authnRequest to Identity Provider.", mee); // response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // } catch (org.opensaml.xml.security.SecurityException e) { // log.error("Unable to retrieve signing credential", e); // response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // } // } // } // Path: mujina-sp/src/test/java/nl/surfnet/mujina/controllers/tests/SpRestAPITest.java import java.io.IOException; import javax.servlet.ServletException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.spring.SAMLAuthenticationEntryPoint; import static junit.framework.Assert.assertTrue; package nl.surfnet.mujina.controllers.tests; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext-sp-config.xml", "classpath:applicationContext-property-mappings.xml", "classpath:applicationContext-spring-security.xml", "classpath:api-servlet.xml"}) public class SpRestAPITest { public static final String SIGN_ON_SERVICE_URL = "http://www.test.nl/"; @Autowired
private SpConfiguration configuration;
alleveenstra/Mujina
mujina-sp/src/test/java/nl/surfnet/mujina/controllers/tests/SpRestAPITest.java
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java // public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { // // private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class); // // private final TimeService timeService; // private final IDService idService; // // private String assertionConsumerServiceURL; // private BindingAdapter bindingAdapter; // private CredentialResolver credentialResolver; // // private SpConfiguration spConfiguration; // // public SAMLAuthenticationEntryPoint(TimeService timeService, IDService idService) { // super(); // this.timeService = timeService; // this.idService = idService; // } // // @Required // public void setAssertionConsumerServiceURL(String assertionConsumerServiceURL) { // this.assertionConsumerServiceURL = assertionConsumerServiceURL; // } // // @Required // public void setBindingAdapter(BindingAdapter bindingAdapter) { // this.bindingAdapter = bindingAdapter; // } // // // @Required // public void setCredentialResolver(CredentialResolver credentialResolver) { // this.credentialResolver = credentialResolver; // } // // public void setConfiguration(final SpConfiguration spConfiguration) { // this.spConfiguration = spConfiguration; // } // // @Override // public void commence(HttpServletRequest request, // HttpServletResponse response, // AuthenticationException authException) throws IOException, ServletException { // // AuthnRequestGenerator authnRequestGenerator = new AuthnRequestGenerator(spConfiguration.getEntityID(), timeService, idService); // EndpointGenerator endpointGenerator = new EndpointGenerator(); // // final String singleSignOnServiceURL = spConfiguration.getSingleSignOnServiceURL(); // // Endpoint endpoint = endpointGenerator.generateEndpoint(SingleSignOnService.DEFAULT_ELEMENT_NAME, singleSignOnServiceURL, assertionConsumerServiceURL); // // AuthnRequest authnReqeust = authnRequestGenerator.generateAuthnRequest(singleSignOnServiceURL, assertionConsumerServiceURL); // // log.debug("Sending authnRequest to {}", singleSignOnServiceURL); // // try { // CriteriaSet criteriaSet = new CriteriaSet(); // criteriaSet.add(new EntityIDCriteria(spConfiguration.getEntityID())); // criteriaSet.add(new UsageCriteria(UsageType.SIGNING)); // // Credential signingCredential = credentialResolver.resolveSingle(criteriaSet); // Validate.notNull(signingCredential); // // bindingAdapter.sendSAMLMessage(authnReqeust, endpoint, signingCredential, response); // } catch (MessageEncodingException mee) { // log.error("Could not send authnRequest to Identity Provider.", mee); // response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // } catch (org.opensaml.xml.security.SecurityException e) { // log.error("Unable to retrieve signing credential", e); // response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // } // } // }
import java.io.IOException; import javax.servlet.ServletException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.spring.SAMLAuthenticationEntryPoint; import static junit.framework.Assert.assertTrue;
package nl.surfnet.mujina.controllers.tests; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext-sp-config.xml", "classpath:applicationContext-property-mappings.xml", "classpath:applicationContext-spring-security.xml", "classpath:api-servlet.xml"}) public class SpRestAPITest { public static final String SIGN_ON_SERVICE_URL = "http://www.test.nl/"; @Autowired private SpConfiguration configuration; @Autowired
// Path: mujina-sp/src/main/java/nl/surfnet/mujina/model/SpConfiguration.java // public interface SpConfiguration extends CommonConfiguration { // public void setSingleSignOnServiceURL(String singleSignOnServiceURL); // public String getSingleSignOnServiceURL(); // } // // Path: mujina-sp/src/main/java/nl/surfnet/mujina/spring/SAMLAuthenticationEntryPoint.java // public class SAMLAuthenticationEntryPoint implements AuthenticationEntryPoint { // // private final static Logger log = LoggerFactory.getLogger(SAMLAuthenticationEntryPoint.class); // // private final TimeService timeService; // private final IDService idService; // // private String assertionConsumerServiceURL; // private BindingAdapter bindingAdapter; // private CredentialResolver credentialResolver; // // private SpConfiguration spConfiguration; // // public SAMLAuthenticationEntryPoint(TimeService timeService, IDService idService) { // super(); // this.timeService = timeService; // this.idService = idService; // } // // @Required // public void setAssertionConsumerServiceURL(String assertionConsumerServiceURL) { // this.assertionConsumerServiceURL = assertionConsumerServiceURL; // } // // @Required // public void setBindingAdapter(BindingAdapter bindingAdapter) { // this.bindingAdapter = bindingAdapter; // } // // // @Required // public void setCredentialResolver(CredentialResolver credentialResolver) { // this.credentialResolver = credentialResolver; // } // // public void setConfiguration(final SpConfiguration spConfiguration) { // this.spConfiguration = spConfiguration; // } // // @Override // public void commence(HttpServletRequest request, // HttpServletResponse response, // AuthenticationException authException) throws IOException, ServletException { // // AuthnRequestGenerator authnRequestGenerator = new AuthnRequestGenerator(spConfiguration.getEntityID(), timeService, idService); // EndpointGenerator endpointGenerator = new EndpointGenerator(); // // final String singleSignOnServiceURL = spConfiguration.getSingleSignOnServiceURL(); // // Endpoint endpoint = endpointGenerator.generateEndpoint(SingleSignOnService.DEFAULT_ELEMENT_NAME, singleSignOnServiceURL, assertionConsumerServiceURL); // // AuthnRequest authnReqeust = authnRequestGenerator.generateAuthnRequest(singleSignOnServiceURL, assertionConsumerServiceURL); // // log.debug("Sending authnRequest to {}", singleSignOnServiceURL); // // try { // CriteriaSet criteriaSet = new CriteriaSet(); // criteriaSet.add(new EntityIDCriteria(spConfiguration.getEntityID())); // criteriaSet.add(new UsageCriteria(UsageType.SIGNING)); // // Credential signingCredential = credentialResolver.resolveSingle(criteriaSet); // Validate.notNull(signingCredential); // // bindingAdapter.sendSAMLMessage(authnReqeust, endpoint, signingCredential, response); // } catch (MessageEncodingException mee) { // log.error("Could not send authnRequest to Identity Provider.", mee); // response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // } catch (org.opensaml.xml.security.SecurityException e) { // log.error("Unable to retrieve signing credential", e); // response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); // } // } // } // Path: mujina-sp/src/test/java/nl/surfnet/mujina/controllers/tests/SpRestAPITest.java import java.io.IOException; import javax.servlet.ServletException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import nl.surfnet.mujina.model.SpConfiguration; import nl.surfnet.mujina.spring.SAMLAuthenticationEntryPoint; import static junit.framework.Assert.assertTrue; package nl.surfnet.mujina.controllers.tests; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext-sp-config.xml", "classpath:applicationContext-property-mappings.xml", "classpath:applicationContext-spring-security.xml", "classpath:api-servlet.xml"}) public class SpRestAPITest { public static final String SIGN_ON_SERVICE_URL = "http://www.test.nl/"; @Autowired private SpConfiguration configuration; @Autowired
private SAMLAuthenticationEntryPoint samlAuthenticationEntryPoint;
box/box-android-sdk
box-content-sdk/src/main/java/com/box/androidsdk/content/utils/BoxContentProvider.java
// Path: box-content-sdk/src/main/java/com/box/androidsdk/content/BoxConfig.java // public class BoxConfig { // // private static BoxCache mCache = null; // // /** // * Flag for whether logging is enabled. This will log all requests and responses made by the SDK // */ // public static boolean IS_LOG_ENABLED = false; // // /** // * Flag for whether the app is currently run in debug mode. This is set by the {@link com.box.androidsdk.content.models.BoxSession} // * object and is determined from the {@link android.content.pm.ApplicationInfo#FLAG_DEBUGGABLE} // */ // public static boolean IS_DEBUG = false; // // /** // * Client id used for the OAuth flow // */ // public static String CLIENT_ID = null; // // /** // * Client secret used for the OAuth flow // */ // public static String CLIENT_SECRET = null; // // /** // * Sets whether sessions should authentivate with the Box Application if available. // */ // public static boolean ENABLE_BOX_APP_AUTHENTICATION = false; // // /** // * The redirect url used with OAuth flow // */ // public static String REDIRECT_URL = "https://app.box.com/static/sync_redirect.html"; // // /** // * Device name used for the OAuth flow and refreshing // */ // public static String DEVICE_NAME = null; // // /** // * Device id used for the OAuth flow and refreshing // */ // public static String DEVICE_ID = null; // // /** // * Application context to be used by box sessions when necessary to show ui. // */ // public static Context APPLICATION_CONTEXT = null; // // /** // * Sets the cache implementation that BoxRequests that implement {@link com.box.androidsdk.content.requests.BoxCacheableRequest} // * will use when the fromCache flag is enabled // * // * @param cache the cache implementation to use // */ // public static void setCache(BoxCache cache) { // mCache = cache; // } // // /** // * Returns the cache implementation that has been set for the SDK // * // * @return the cache implementation // */ // public static BoxCache getCache() { // return mCache; // } // // /** // * Version string // */ // public static String SDK_VERSION = "5.0.0"; // // /** // * Optional paramater for whether authentication should use // * WindowManager.LayoutParams.FLAG_SECURE before loading UI. // */ // public static boolean IS_FLAG_SECURE = false; // // /** // * This config enables TLS 1.1 and 1.2 on kitkat and below versions which are disabled by default. // */ // public static boolean ENABLE_TLS_FOR_PRE_20 = Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH; // }
import android.content.ContentProvider; import android.content.ContentValues; import android.database.Cursor; import android.net.Uri; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.box.androidsdk.content.BoxConfig;
package com.box.androidsdk.content.utils; public class BoxContentProvider extends ContentProvider { @Override public boolean onCreate() {
// Path: box-content-sdk/src/main/java/com/box/androidsdk/content/BoxConfig.java // public class BoxConfig { // // private static BoxCache mCache = null; // // /** // * Flag for whether logging is enabled. This will log all requests and responses made by the SDK // */ // public static boolean IS_LOG_ENABLED = false; // // /** // * Flag for whether the app is currently run in debug mode. This is set by the {@link com.box.androidsdk.content.models.BoxSession} // * object and is determined from the {@link android.content.pm.ApplicationInfo#FLAG_DEBUGGABLE} // */ // public static boolean IS_DEBUG = false; // // /** // * Client id used for the OAuth flow // */ // public static String CLIENT_ID = null; // // /** // * Client secret used for the OAuth flow // */ // public static String CLIENT_SECRET = null; // // /** // * Sets whether sessions should authentivate with the Box Application if available. // */ // public static boolean ENABLE_BOX_APP_AUTHENTICATION = false; // // /** // * The redirect url used with OAuth flow // */ // public static String REDIRECT_URL = "https://app.box.com/static/sync_redirect.html"; // // /** // * Device name used for the OAuth flow and refreshing // */ // public static String DEVICE_NAME = null; // // /** // * Device id used for the OAuth flow and refreshing // */ // public static String DEVICE_ID = null; // // /** // * Application context to be used by box sessions when necessary to show ui. // */ // public static Context APPLICATION_CONTEXT = null; // // /** // * Sets the cache implementation that BoxRequests that implement {@link com.box.androidsdk.content.requests.BoxCacheableRequest} // * will use when the fromCache flag is enabled // * // * @param cache the cache implementation to use // */ // public static void setCache(BoxCache cache) { // mCache = cache; // } // // /** // * Returns the cache implementation that has been set for the SDK // * // * @return the cache implementation // */ // public static BoxCache getCache() { // return mCache; // } // // /** // * Version string // */ // public static String SDK_VERSION = "5.0.0"; // // /** // * Optional paramater for whether authentication should use // * WindowManager.LayoutParams.FLAG_SECURE before loading UI. // */ // public static boolean IS_FLAG_SECURE = false; // // /** // * This config enables TLS 1.1 and 1.2 on kitkat and below versions which are disabled by default. // */ // public static boolean ENABLE_TLS_FOR_PRE_20 = Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH; // } // Path: box-content-sdk/src/main/java/com/box/androidsdk/content/utils/BoxContentProvider.java import android.content.ContentProvider; import android.content.ContentValues; import android.database.Cursor; import android.net.Uri; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.box.androidsdk.content.BoxConfig; package com.box.androidsdk.content.utils; public class BoxContentProvider extends ContentProvider { @Override public boolean onCreate() {
BoxConfig.APPLICATION_CONTEXT = getContext();
box/box-android-sdk
box-content-sdk/src/main/java/com/box/androidsdk/content/requests/BoxHttpRequest.java
// Path: box-content-sdk/src/main/java/com/box/androidsdk/content/BoxConfig.java // public class BoxConfig { // // private static BoxCache mCache = null; // // /** // * Flag for whether logging is enabled. This will log all requests and responses made by the SDK // */ // public static boolean IS_LOG_ENABLED = false; // // /** // * Flag for whether the app is currently run in debug mode. This is set by the {@link com.box.androidsdk.content.models.BoxSession} // * object and is determined from the {@link android.content.pm.ApplicationInfo#FLAG_DEBUGGABLE} // */ // public static boolean IS_DEBUG = false; // // /** // * Client id used for the OAuth flow // */ // public static String CLIENT_ID = null; // // /** // * Client secret used for the OAuth flow // */ // public static String CLIENT_SECRET = null; // // /** // * Sets whether sessions should authentivate with the Box Application if available. // */ // public static boolean ENABLE_BOX_APP_AUTHENTICATION = false; // // /** // * The redirect url used with OAuth flow // */ // public static String REDIRECT_URL = "https://app.box.com/static/sync_redirect.html"; // // /** // * Device name used for the OAuth flow and refreshing // */ // public static String DEVICE_NAME = null; // // /** // * Device id used for the OAuth flow and refreshing // */ // public static String DEVICE_ID = null; // // /** // * Application context to be used by box sessions when necessary to show ui. // */ // public static Context APPLICATION_CONTEXT = null; // // /** // * Sets the cache implementation that BoxRequests that implement {@link com.box.androidsdk.content.requests.BoxCacheableRequest} // * will use when the fromCache flag is enabled // * // * @param cache the cache implementation to use // */ // public static void setCache(BoxCache cache) { // mCache = cache; // } // // /** // * Returns the cache implementation that has been set for the SDK // * // * @return the cache implementation // */ // public static BoxCache getCache() { // return mCache; // } // // /** // * Version string // */ // public static String SDK_VERSION = "5.0.0"; // // /** // * Optional paramater for whether authentication should use // * WindowManager.LayoutParams.FLAG_SECURE before loading UI. // */ // public static boolean IS_FLAG_SECURE = false; // // /** // * This config enables TLS 1.1 and 1.2 on kitkat and below versions which are disabled by default. // */ // public static boolean ENABLE_TLS_FOR_PRE_20 = Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH; // }
import com.box.androidsdk.content.BoxConfig; import com.box.androidsdk.content.listeners.ProgressListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import javax.net.ssl.HttpsURLConnection;
package com.box.androidsdk.content.requests; /** * Class that represents an HTTP request. */ class BoxHttpRequest { protected final HttpURLConnection mUrlConnection; protected final ProgressListener mListener; /** * Constructs an HTTP request with the default parameters. * * @param url URL to connect to. * @param method method type for the HTTP request. * @param listener progress listener for a long-running API call. * @throws IOException */ public BoxHttpRequest(URL url, BoxRequest.Methods method, ProgressListener listener) throws IOException { mUrlConnection = (HttpURLConnection) url.openConnection(); mUrlConnection.setRequestMethod(method.toString()); mListener = listener; // enables TLS 1.1 and 1.2 which is disabled by default on kitkat and below
// Path: box-content-sdk/src/main/java/com/box/androidsdk/content/BoxConfig.java // public class BoxConfig { // // private static BoxCache mCache = null; // // /** // * Flag for whether logging is enabled. This will log all requests and responses made by the SDK // */ // public static boolean IS_LOG_ENABLED = false; // // /** // * Flag for whether the app is currently run in debug mode. This is set by the {@link com.box.androidsdk.content.models.BoxSession} // * object and is determined from the {@link android.content.pm.ApplicationInfo#FLAG_DEBUGGABLE} // */ // public static boolean IS_DEBUG = false; // // /** // * Client id used for the OAuth flow // */ // public static String CLIENT_ID = null; // // /** // * Client secret used for the OAuth flow // */ // public static String CLIENT_SECRET = null; // // /** // * Sets whether sessions should authentivate with the Box Application if available. // */ // public static boolean ENABLE_BOX_APP_AUTHENTICATION = false; // // /** // * The redirect url used with OAuth flow // */ // public static String REDIRECT_URL = "https://app.box.com/static/sync_redirect.html"; // // /** // * Device name used for the OAuth flow and refreshing // */ // public static String DEVICE_NAME = null; // // /** // * Device id used for the OAuth flow and refreshing // */ // public static String DEVICE_ID = null; // // /** // * Application context to be used by box sessions when necessary to show ui. // */ // public static Context APPLICATION_CONTEXT = null; // // /** // * Sets the cache implementation that BoxRequests that implement {@link com.box.androidsdk.content.requests.BoxCacheableRequest} // * will use when the fromCache flag is enabled // * // * @param cache the cache implementation to use // */ // public static void setCache(BoxCache cache) { // mCache = cache; // } // // /** // * Returns the cache implementation that has been set for the SDK // * // * @return the cache implementation // */ // public static BoxCache getCache() { // return mCache; // } // // /** // * Version string // */ // public static String SDK_VERSION = "5.0.0"; // // /** // * Optional paramater for whether authentication should use // * WindowManager.LayoutParams.FLAG_SECURE before loading UI. // */ // public static boolean IS_FLAG_SECURE = false; // // /** // * This config enables TLS 1.1 and 1.2 on kitkat and below versions which are disabled by default. // */ // public static boolean ENABLE_TLS_FOR_PRE_20 = Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH; // } // Path: box-content-sdk/src/main/java/com/box/androidsdk/content/requests/BoxHttpRequest.java import com.box.androidsdk.content.BoxConfig; import com.box.androidsdk.content.listeners.ProgressListener; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import javax.net.ssl.HttpsURLConnection; package com.box.androidsdk.content.requests; /** * Class that represents an HTTP request. */ class BoxHttpRequest { protected final HttpURLConnection mUrlConnection; protected final ProgressListener mListener; /** * Constructs an HTTP request with the default parameters. * * @param url URL to connect to. * @param method method type for the HTTP request. * @param listener progress listener for a long-running API call. * @throws IOException */ public BoxHttpRequest(URL url, BoxRequest.Methods method, ProgressListener listener) throws IOException { mUrlConnection = (HttpURLConnection) url.openConnection(); mUrlConnection.setRequestMethod(method.toString()); mListener = listener; // enables TLS 1.1 and 1.2 which is disabled by default on kitkat and below
if (BoxConfig.ENABLE_TLS_FOR_PRE_20 && mUrlConnection instanceof HttpsURLConnection) {
box/box-android-sdk
box-content-sdk/src/main/java/com/box/androidsdk/content/BoxException.java
// Path: box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxError.java // public class BoxError extends BoxJsonObject { // // //private static final long serialVersionUID = 1626798809346520004L; // public static final String FIELD_TYPE = "type"; // public static final String FIELD_STATUS = "status"; // public static final String FIELD_CODE = "code"; // public static final String FIELD_CONTEXT_INFO = "context_info"; // public static final String FIELD_HELP_URL = "help_url"; // public static final String FIELD_MESSAGE = "message"; // public static final String FIELD_REQUEST_ID = "request_id"; // public static final String FIELD_ERROR = "error"; // public static final String FIELD_ERROR_DESCRIPTION = "error_description"; // // // /** // * Constructs an empty BoxError object. // */ // public BoxError() { // super(); // } // // // /** // * Constructs a BoxError with the provided JsonObject. // * @param jsonObject jsonObject to use to create an instance of this class. // */ // public BoxError(JsonObject jsonObject) { // super(jsonObject); // } // // // /** // * Gets the type of the error. // * // * @return the error type. // */ // public String getType() { // String type = getPropertyAsString(FIELD_TYPE); // return type; // } // // /** // * // * @return status code of the error. // */ // public Integer getStatus(){ // return getPropertyAsInt(FIELD_STATUS); // } // // /** // * // * @return the code of the error. // */ // public String getCode(){ // return getPropertyAsString(FIELD_CODE); // } // // public ErrorContext getContextInfo(){ // return getPropertyAsJsonObject(BoxJsonObject.getBoxJsonObjectCreator(ErrorContext.class),FIELD_CONTEXT_INFO); // } // // /** // * // * @return a url to get more information about the error. // */ // public String getFieldHelpUrl(){ // return getPropertyAsString(FIELD_HELP_URL); // } // // /** // * // * @return get a human readable string describing the error. // */ // public String getMessage(){ // return getPropertyAsString(FIELD_MESSAGE); // } // // /** // * // * @return the id of the error. // */ // public String getRequestId(){ // return getPropertyAsString(FIELD_REQUEST_ID); // } // // /** // * // * @return the error code. // */ // public String getError(){ // String error = getPropertyAsString(FIELD_ERROR); // if (error == null) { // error = getCode(); // } // return error; // } // // // /** // * // * @return the error description. // */ // public String getErrorDescription(){ // return getPropertyAsString(FIELD_ERROR_DESCRIPTION); // } // // // public static class ErrorContext extends BoxJsonObject { // // public static final String FIELD_CONFLICTS = "conflicts"; // public static final String FIELD_CONFLICTING_PART = "conflicting_part"; // // // /** // * // * @return a list of the items that caused a conflict. // */ // public ArrayList<BoxEntity> getConflicts(){ // return (ArrayList<BoxEntity>)getPropertyAsJsonObjectArray(BoxEntity.getBoxJsonObjectCreator(), FIELD_CONFLICTS); // } // // /** // * // * @return a box entity that is involved with a particular part of an error. // */ // public BoxUploadSessionPart getConflictingPart(){ // // currently only the multiput upload endpoint is known to return this type of error context object. // BoxUploadSessionPart entity = getPropertyAsJsonObject(getBoxJsonObjectCreator(BoxUploadSessionPart.class), FIELD_CONFLICTING_PART); // return entity; // } // // } // }
import com.box.androidsdk.content.models.BoxError; import com.box.androidsdk.content.requests.BoxHttpResponse; import java.io.StreamCorruptedException; import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.UnknownHostException; import javax.net.ssl.SSLException;
private static Throwable getRootCause(Throwable cause){ if (cause instanceof BoxException){ return cause.getCause(); } return cause; } /** * Gets the response code returned by the server when this exception was thrown. * * @return the response code returned by the server. */ public int getResponseCode() { return this.responseCode; } /** * Gets the body of the response returned by the server when this exception was thrown. * * @return the body of the response returned by the server. */ public String getResponse() { return this.response; } /** * Gets the server response as a BoxError. * * @return the response as a BoxError, or null if the response cannot be converted. */
// Path: box-content-sdk/src/main/java/com/box/androidsdk/content/models/BoxError.java // public class BoxError extends BoxJsonObject { // // //private static final long serialVersionUID = 1626798809346520004L; // public static final String FIELD_TYPE = "type"; // public static final String FIELD_STATUS = "status"; // public static final String FIELD_CODE = "code"; // public static final String FIELD_CONTEXT_INFO = "context_info"; // public static final String FIELD_HELP_URL = "help_url"; // public static final String FIELD_MESSAGE = "message"; // public static final String FIELD_REQUEST_ID = "request_id"; // public static final String FIELD_ERROR = "error"; // public static final String FIELD_ERROR_DESCRIPTION = "error_description"; // // // /** // * Constructs an empty BoxError object. // */ // public BoxError() { // super(); // } // // // /** // * Constructs a BoxError with the provided JsonObject. // * @param jsonObject jsonObject to use to create an instance of this class. // */ // public BoxError(JsonObject jsonObject) { // super(jsonObject); // } // // // /** // * Gets the type of the error. // * // * @return the error type. // */ // public String getType() { // String type = getPropertyAsString(FIELD_TYPE); // return type; // } // // /** // * // * @return status code of the error. // */ // public Integer getStatus(){ // return getPropertyAsInt(FIELD_STATUS); // } // // /** // * // * @return the code of the error. // */ // public String getCode(){ // return getPropertyAsString(FIELD_CODE); // } // // public ErrorContext getContextInfo(){ // return getPropertyAsJsonObject(BoxJsonObject.getBoxJsonObjectCreator(ErrorContext.class),FIELD_CONTEXT_INFO); // } // // /** // * // * @return a url to get more information about the error. // */ // public String getFieldHelpUrl(){ // return getPropertyAsString(FIELD_HELP_URL); // } // // /** // * // * @return get a human readable string describing the error. // */ // public String getMessage(){ // return getPropertyAsString(FIELD_MESSAGE); // } // // /** // * // * @return the id of the error. // */ // public String getRequestId(){ // return getPropertyAsString(FIELD_REQUEST_ID); // } // // /** // * // * @return the error code. // */ // public String getError(){ // String error = getPropertyAsString(FIELD_ERROR); // if (error == null) { // error = getCode(); // } // return error; // } // // // /** // * // * @return the error description. // */ // public String getErrorDescription(){ // return getPropertyAsString(FIELD_ERROR_DESCRIPTION); // } // // // public static class ErrorContext extends BoxJsonObject { // // public static final String FIELD_CONFLICTS = "conflicts"; // public static final String FIELD_CONFLICTING_PART = "conflicting_part"; // // // /** // * // * @return a list of the items that caused a conflict. // */ // public ArrayList<BoxEntity> getConflicts(){ // return (ArrayList<BoxEntity>)getPropertyAsJsonObjectArray(BoxEntity.getBoxJsonObjectCreator(), FIELD_CONFLICTS); // } // // /** // * // * @return a box entity that is involved with a particular part of an error. // */ // public BoxUploadSessionPart getConflictingPart(){ // // currently only the multiput upload endpoint is known to return this type of error context object. // BoxUploadSessionPart entity = getPropertyAsJsonObject(getBoxJsonObjectCreator(BoxUploadSessionPart.class), FIELD_CONFLICTING_PART); // return entity; // } // // } // } // Path: box-content-sdk/src/main/java/com/box/androidsdk/content/BoxException.java import com.box.androidsdk.content.models.BoxError; import com.box.androidsdk.content.requests.BoxHttpResponse; import java.io.StreamCorruptedException; import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.UnknownHostException; import javax.net.ssl.SSLException; private static Throwable getRootCause(Throwable cause){ if (cause instanceof BoxException){ return cause.getCause(); } return cause; } /** * Gets the response code returned by the server when this exception was thrown. * * @return the response code returned by the server. */ public int getResponseCode() { return this.responseCode; } /** * Gets the body of the response returned by the server when this exception was thrown. * * @return the body of the response returned by the server. */ public String getResponse() { return this.response; } /** * Gets the server response as a BoxError. * * @return the response as a BoxError, or null if the response cannot be converted. */
public BoxError getAsBoxError() {
Netflix/denominator
route53/src/test/java/denominator/route53/Route53ProviderTest.java
// Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object anonymous() { // return credentials(AnonymousCredentials.INSTANCE); // } // // Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object credentials(Object firstPart, Object secondPart) { // return credentials(ListCredentials.from(firstPart, secondPart)); // } // // Path: core/src/main/java/denominator/Providers.java // public static Iterable<Provider> list() { // return ServiceLoader.load(Provider.class); // } // // Path: core/src/main/java/denominator/Providers.java // public static Object provide(denominator.Provider provider) { // return new ProvideProvider(provider); // }
import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import dagger.ObjectGraph; import denominator.Credentials.MapCredentials; import denominator.DNSApiManager; import denominator.Provider; import static denominator.CredentialsConfiguration.anonymous; import static denominator.CredentialsConfiguration.credentials; import static denominator.Denominator.create; import static denominator.Providers.list; import static denominator.Providers.provide; import static org.assertj.core.api.Assertions.assertThat;
package denominator.route53; public class Route53ProviderTest { @Rule public final ExpectedException thrown = ExpectedException.none(); private static final Provider PROVIDER = new Route53Provider(); @Test public void testRoute53Metadata() { assertThat(PROVIDER.name()).isEqualTo("route53"); assertThat(PROVIDER.supportsDuplicateZoneNames()).isTrue(); assertThat(PROVIDER.credentialTypeToParameterNames()) .containsEntry("accessKey", Arrays.asList("accessKey", "secretKey")) .containsEntry("session", Arrays.asList("accessKey", "secretKey", "sessionToken")); } @Test public void testRoute53Registered() {
// Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object anonymous() { // return credentials(AnonymousCredentials.INSTANCE); // } // // Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object credentials(Object firstPart, Object secondPart) { // return credentials(ListCredentials.from(firstPart, secondPart)); // } // // Path: core/src/main/java/denominator/Providers.java // public static Iterable<Provider> list() { // return ServiceLoader.load(Provider.class); // } // // Path: core/src/main/java/denominator/Providers.java // public static Object provide(denominator.Provider provider) { // return new ProvideProvider(provider); // } // Path: route53/src/test/java/denominator/route53/Route53ProviderTest.java import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import dagger.ObjectGraph; import denominator.Credentials.MapCredentials; import denominator.DNSApiManager; import denominator.Provider; import static denominator.CredentialsConfiguration.anonymous; import static denominator.CredentialsConfiguration.credentials; import static denominator.Denominator.create; import static denominator.Providers.list; import static denominator.Providers.provide; import static org.assertj.core.api.Assertions.assertThat; package denominator.route53; public class Route53ProviderTest { @Rule public final ExpectedException thrown = ExpectedException.none(); private static final Provider PROVIDER = new Route53Provider(); @Test public void testRoute53Metadata() { assertThat(PROVIDER.name()).isEqualTo("route53"); assertThat(PROVIDER.supportsDuplicateZoneNames()).isTrue(); assertThat(PROVIDER.credentialTypeToParameterNames()) .containsEntry("accessKey", Arrays.asList("accessKey", "secretKey")) .containsEntry("session", Arrays.asList("accessKey", "secretKey", "sessionToken")); } @Test public void testRoute53Registered() {
assertThat(list()).contains(PROVIDER);
Netflix/denominator
route53/src/test/java/denominator/route53/Route53ProviderTest.java
// Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object anonymous() { // return credentials(AnonymousCredentials.INSTANCE); // } // // Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object credentials(Object firstPart, Object secondPart) { // return credentials(ListCredentials.from(firstPart, secondPart)); // } // // Path: core/src/main/java/denominator/Providers.java // public static Iterable<Provider> list() { // return ServiceLoader.load(Provider.class); // } // // Path: core/src/main/java/denominator/Providers.java // public static Object provide(denominator.Provider provider) { // return new ProvideProvider(provider); // }
import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import dagger.ObjectGraph; import denominator.Credentials.MapCredentials; import denominator.DNSApiManager; import denominator.Provider; import static denominator.CredentialsConfiguration.anonymous; import static denominator.CredentialsConfiguration.credentials; import static denominator.Denominator.create; import static denominator.Providers.list; import static denominator.Providers.provide; import static org.assertj.core.api.Assertions.assertThat;
package denominator.route53; public class Route53ProviderTest { @Rule public final ExpectedException thrown = ExpectedException.none(); private static final Provider PROVIDER = new Route53Provider(); @Test public void testRoute53Metadata() { assertThat(PROVIDER.name()).isEqualTo("route53"); assertThat(PROVIDER.supportsDuplicateZoneNames()).isTrue(); assertThat(PROVIDER.credentialTypeToParameterNames()) .containsEntry("accessKey", Arrays.asList("accessKey", "secretKey")) .containsEntry("session", Arrays.asList("accessKey", "secretKey", "sessionToken")); } @Test public void testRoute53Registered() { assertThat(list()).contains(PROVIDER); } @Test public void testProviderWiresRoute53ZoneApiWithAccessKeyCredentials() {
// Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object anonymous() { // return credentials(AnonymousCredentials.INSTANCE); // } // // Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object credentials(Object firstPart, Object secondPart) { // return credentials(ListCredentials.from(firstPart, secondPart)); // } // // Path: core/src/main/java/denominator/Providers.java // public static Iterable<Provider> list() { // return ServiceLoader.load(Provider.class); // } // // Path: core/src/main/java/denominator/Providers.java // public static Object provide(denominator.Provider provider) { // return new ProvideProvider(provider); // } // Path: route53/src/test/java/denominator/route53/Route53ProviderTest.java import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import dagger.ObjectGraph; import denominator.Credentials.MapCredentials; import denominator.DNSApiManager; import denominator.Provider; import static denominator.CredentialsConfiguration.anonymous; import static denominator.CredentialsConfiguration.credentials; import static denominator.Denominator.create; import static denominator.Providers.list; import static denominator.Providers.provide; import static org.assertj.core.api.Assertions.assertThat; package denominator.route53; public class Route53ProviderTest { @Rule public final ExpectedException thrown = ExpectedException.none(); private static final Provider PROVIDER = new Route53Provider(); @Test public void testRoute53Metadata() { assertThat(PROVIDER.name()).isEqualTo("route53"); assertThat(PROVIDER.supportsDuplicateZoneNames()).isTrue(); assertThat(PROVIDER.credentialTypeToParameterNames()) .containsEntry("accessKey", Arrays.asList("accessKey", "secretKey")) .containsEntry("session", Arrays.asList("accessKey", "secretKey", "sessionToken")); } @Test public void testRoute53Registered() { assertThat(list()).contains(PROVIDER); } @Test public void testProviderWiresRoute53ZoneApiWithAccessKeyCredentials() {
DNSApiManager manager = create(PROVIDER, credentials("accesskey", "secretkey"));
Netflix/denominator
route53/src/test/java/denominator/route53/Route53ProviderTest.java
// Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object anonymous() { // return credentials(AnonymousCredentials.INSTANCE); // } // // Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object credentials(Object firstPart, Object secondPart) { // return credentials(ListCredentials.from(firstPart, secondPart)); // } // // Path: core/src/main/java/denominator/Providers.java // public static Iterable<Provider> list() { // return ServiceLoader.load(Provider.class); // } // // Path: core/src/main/java/denominator/Providers.java // public static Object provide(denominator.Provider provider) { // return new ProvideProvider(provider); // }
import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import dagger.ObjectGraph; import denominator.Credentials.MapCredentials; import denominator.DNSApiManager; import denominator.Provider; import static denominator.CredentialsConfiguration.anonymous; import static denominator.CredentialsConfiguration.credentials; import static denominator.Denominator.create; import static denominator.Providers.list; import static denominator.Providers.provide; import static org.assertj.core.api.Assertions.assertThat;
@Test public void testProviderWiresRoute53ZoneApiWithAccessKeyCredentials() { DNSApiManager manager = create(PROVIDER, credentials("accesskey", "secretkey")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); manager = create("route53", credentials("accesskey", "secretkey")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); Map<String, String> map = new LinkedHashMap<String, String>(); map.put("accesskey", "A"); map.put("secretkey", "S"); manager = create("route53", credentials(MapCredentials.from(map))); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); } @Test public void testProviderWiresRoute53ZoneApiWithSessionCredentials() { DNSApiManager manager = create(PROVIDER, credentials("accesskey", "secretkey", "sessionToken")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); manager = create("route53", credentials("accesskey", "secretkey", "sessionToken")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); } @Test public void testCredentialsRequired() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage( "no credentials supplied. route53 requires one of the following forms: when type is accessKey: accessKey,secretKey; session: accessKey,secretKey,sessionToken"); // manually passing anonymous in case this test is executed from EC2 // where IAM profiles are present.
// Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object anonymous() { // return credentials(AnonymousCredentials.INSTANCE); // } // // Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object credentials(Object firstPart, Object secondPart) { // return credentials(ListCredentials.from(firstPart, secondPart)); // } // // Path: core/src/main/java/denominator/Providers.java // public static Iterable<Provider> list() { // return ServiceLoader.load(Provider.class); // } // // Path: core/src/main/java/denominator/Providers.java // public static Object provide(denominator.Provider provider) { // return new ProvideProvider(provider); // } // Path: route53/src/test/java/denominator/route53/Route53ProviderTest.java import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import dagger.ObjectGraph; import denominator.Credentials.MapCredentials; import denominator.DNSApiManager; import denominator.Provider; import static denominator.CredentialsConfiguration.anonymous; import static denominator.CredentialsConfiguration.credentials; import static denominator.Denominator.create; import static denominator.Providers.list; import static denominator.Providers.provide; import static org.assertj.core.api.Assertions.assertThat; @Test public void testProviderWiresRoute53ZoneApiWithAccessKeyCredentials() { DNSApiManager manager = create(PROVIDER, credentials("accesskey", "secretkey")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); manager = create("route53", credentials("accesskey", "secretkey")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); Map<String, String> map = new LinkedHashMap<String, String>(); map.put("accesskey", "A"); map.put("secretkey", "S"); manager = create("route53", credentials(MapCredentials.from(map))); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); } @Test public void testProviderWiresRoute53ZoneApiWithSessionCredentials() { DNSApiManager manager = create(PROVIDER, credentials("accesskey", "secretkey", "sessionToken")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); manager = create("route53", credentials("accesskey", "secretkey", "sessionToken")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); } @Test public void testCredentialsRequired() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage( "no credentials supplied. route53 requires one of the following forms: when type is accessKey: accessKey,secretKey; session: accessKey,secretKey,sessionToken"); // manually passing anonymous in case this test is executed from EC2 // where IAM profiles are present.
create(PROVIDER, anonymous()).api().zones().iterator();
Netflix/denominator
route53/src/test/java/denominator/route53/Route53ProviderTest.java
// Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object anonymous() { // return credentials(AnonymousCredentials.INSTANCE); // } // // Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object credentials(Object firstPart, Object secondPart) { // return credentials(ListCredentials.from(firstPart, secondPart)); // } // // Path: core/src/main/java/denominator/Providers.java // public static Iterable<Provider> list() { // return ServiceLoader.load(Provider.class); // } // // Path: core/src/main/java/denominator/Providers.java // public static Object provide(denominator.Provider provider) { // return new ProvideProvider(provider); // }
import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import dagger.ObjectGraph; import denominator.Credentials.MapCredentials; import denominator.DNSApiManager; import denominator.Provider; import static denominator.CredentialsConfiguration.anonymous; import static denominator.CredentialsConfiguration.credentials; import static denominator.Denominator.create; import static denominator.Providers.list; import static denominator.Providers.provide; import static org.assertj.core.api.Assertions.assertThat;
assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); Map<String, String> map = new LinkedHashMap<String, String>(); map.put("accesskey", "A"); map.put("secretkey", "S"); manager = create("route53", credentials(MapCredentials.from(map))); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); } @Test public void testProviderWiresRoute53ZoneApiWithSessionCredentials() { DNSApiManager manager = create(PROVIDER, credentials("accesskey", "secretkey", "sessionToken")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); manager = create("route53", credentials("accesskey", "secretkey", "sessionToken")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); } @Test public void testCredentialsRequired() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage( "no credentials supplied. route53 requires one of the following forms: when type is accessKey: accessKey,secretKey; session: accessKey,secretKey,sessionToken"); // manually passing anonymous in case this test is executed from EC2 // where IAM profiles are present. create(PROVIDER, anonymous()).api().zones().iterator(); } @Test public void testViaDagger() { DNSApiManager manager = ObjectGraph
// Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object anonymous() { // return credentials(AnonymousCredentials.INSTANCE); // } // // Path: core/src/main/java/denominator/CredentialsConfiguration.java // public static Object credentials(Object firstPart, Object secondPart) { // return credentials(ListCredentials.from(firstPart, secondPart)); // } // // Path: core/src/main/java/denominator/Providers.java // public static Iterable<Provider> list() { // return ServiceLoader.load(Provider.class); // } // // Path: core/src/main/java/denominator/Providers.java // public static Object provide(denominator.Provider provider) { // return new ProvideProvider(provider); // } // Path: route53/src/test/java/denominator/route53/Route53ProviderTest.java import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import dagger.ObjectGraph; import denominator.Credentials.MapCredentials; import denominator.DNSApiManager; import denominator.Provider; import static denominator.CredentialsConfiguration.anonymous; import static denominator.CredentialsConfiguration.credentials; import static denominator.Denominator.create; import static denominator.Providers.list; import static denominator.Providers.provide; import static org.assertj.core.api.Assertions.assertThat; assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); Map<String, String> map = new LinkedHashMap<String, String>(); map.put("accesskey", "A"); map.put("secretkey", "S"); manager = create("route53", credentials(MapCredentials.from(map))); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); } @Test public void testProviderWiresRoute53ZoneApiWithSessionCredentials() { DNSApiManager manager = create(PROVIDER, credentials("accesskey", "secretkey", "sessionToken")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); manager = create("route53", credentials("accesskey", "secretkey", "sessionToken")); assertThat(manager.api().zones()).isInstanceOf(Route53ZoneApi.class); } @Test public void testCredentialsRequired() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage( "no credentials supplied. route53 requires one of the following forms: when type is accessKey: accessKey,secretKey; session: accessKey,secretKey,sessionToken"); // manually passing anonymous in case this test is executed from EC2 // where IAM profiles are present. create(PROVIDER, anonymous()).api().zones().iterator(); } @Test public void testViaDagger() { DNSApiManager manager = ObjectGraph
.create(provide(new Route53Provider()), new Route53Provider.Module(),
Netflix/denominator
model/src/main/java/denominator/common/Util.java
// Path: model/src/main/java/denominator/model/rdata/TXTData.java // public final class TXTData extends LinkedHashMap<String, Object> { // // private static final long serialVersionUID = 1L; // // TXTData(String txtdata) { // checkArgument(checkNotNull(txtdata, "txtdata").length() <= 65535, // "txt data is limited to 65535"); // put("txtdata", txtdata); // } // // public static TXTData create(String txtdata) { // return new TXTData(txtdata); // } // // /** // * One or more character-strings. // * // * @since 1.3 // */ // public String txtdata() { // return get("txtdata").toString(); // } // }
import java.io.IOException; import java.io.Reader; import java.net.InetAddress; import java.nio.CharBuffer; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import denominator.model.rdata.AAAAData; import denominator.model.rdata.AData; import denominator.model.rdata.CERTData; import denominator.model.rdata.CNAMEData; import denominator.model.rdata.MXData; import denominator.model.rdata.NAPTRData; import denominator.model.rdata.NSData; import denominator.model.rdata.PTRData; import denominator.model.rdata.SOAData; import denominator.model.rdata.SPFData; import denominator.model.rdata.SRVData; import denominator.model.rdata.SSHFPData; import denominator.model.rdata.TXTData; import static denominator.common.Preconditions.checkNotNull;
} return endOfData(); } }; } public static <T> Filter<T> and(final Filter<T> first, final Filter<? super T> second) { checkNotNull(first, "first"); checkNotNull(second, "second"); return new Filter<T>() { public boolean apply(T in) { if (!first.apply(in)) { return false; } return second.apply(in); } }; } public static String flatten(Map<String, Object> input) { Collection<Object> orderedRdataValues = input.values(); if (orderedRdataValues.size() == 1) { Object rdata = orderedRdataValues.iterator().next(); return rdata instanceof InetAddress ? InetAddress.class.cast(rdata).getHostAddress() : rdata.toString(); } return join(' ', orderedRdataValues.toArray()); } public static Map<String, Object> toMap(String type, String rdata) {
// Path: model/src/main/java/denominator/model/rdata/TXTData.java // public final class TXTData extends LinkedHashMap<String, Object> { // // private static final long serialVersionUID = 1L; // // TXTData(String txtdata) { // checkArgument(checkNotNull(txtdata, "txtdata").length() <= 65535, // "txt data is limited to 65535"); // put("txtdata", txtdata); // } // // public static TXTData create(String txtdata) { // return new TXTData(txtdata); // } // // /** // * One or more character-strings. // * // * @since 1.3 // */ // public String txtdata() { // return get("txtdata").toString(); // } // } // Path: model/src/main/java/denominator/common/Util.java import java.io.IOException; import java.io.Reader; import java.net.InetAddress; import java.nio.CharBuffer; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import denominator.model.rdata.AAAAData; import denominator.model.rdata.AData; import denominator.model.rdata.CERTData; import denominator.model.rdata.CNAMEData; import denominator.model.rdata.MXData; import denominator.model.rdata.NAPTRData; import denominator.model.rdata.NSData; import denominator.model.rdata.PTRData; import denominator.model.rdata.SOAData; import denominator.model.rdata.SPFData; import denominator.model.rdata.SRVData; import denominator.model.rdata.SSHFPData; import denominator.model.rdata.TXTData; import static denominator.common.Preconditions.checkNotNull; } return endOfData(); } }; } public static <T> Filter<T> and(final Filter<T> first, final Filter<? super T> second) { checkNotNull(first, "first"); checkNotNull(second, "second"); return new Filter<T>() { public boolean apply(T in) { if (!first.apply(in)) { return false; } return second.apply(in); } }; } public static String flatten(Map<String, Object> input) { Collection<Object> orderedRdataValues = input.values(); if (orderedRdataValues.size() == 1) { Object rdata = orderedRdataValues.iterator().next(); return rdata instanceof InetAddress ? InetAddress.class.cast(rdata).getHostAddress() : rdata.toString(); } return join(' ', orderedRdataValues.toArray()); } public static Map<String, Object> toMap(String type, String rdata) {
return "TXT".equals(type) ? TXTData.create(rdata) : toMap(type, Util.split(' ', rdata));
Netflix/denominator
dynect/src/main/java/denominator/dynect/DynECTResourceRecordSetApi.java
// Path: model/src/main/java/denominator/common/Util.java // public static <T> T nextOrNull(Iterator<T> it) { // return it.hasNext() ? it.next() : null; // }
import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.inject.Inject; import denominator.ResourceRecordSetApi; import denominator.dynect.DynECT.Record; import denominator.model.ResourceRecordSet; import feign.FeignException; import static denominator.common.Preconditions.checkArgument; import static denominator.common.Preconditions.checkNotNull; import static denominator.common.Util.nextOrNull; import static java.lang.String.format;
public Iterator<ResourceRecordSet<?>> iterator() { try { return api.rrsets(zone).data; } catch (FeignException e) { if (e.getMessage().indexOf("NOT_FOUND") != -1) { throw new IllegalArgumentException("zone " + zone + " not found", e); } throw e; } } @Override public Iterator<ResourceRecordSet<?>> iterateByName(final String name) { checkNotNull(name, "name"); return emptyIteratorOn404(new Iterable<ResourceRecordSet<?>>() { public Iterator<ResourceRecordSet<?>> iterator() { return api.rrsetsInZoneByName(zone, name).data; } }); } @Override public ResourceRecordSet<?> getByNameAndType(final String name, final String type) { checkNotNull(name, "name"); checkNotNull(type, "type"); Iterator<ResourceRecordSet<?>> rrset = emptyIteratorOn404(new Iterable<ResourceRecordSet<?>>() { public Iterator<ResourceRecordSet<?>> iterator() { return api.rrsetsInZoneByNameAndType(zone, name, type).data; } });
// Path: model/src/main/java/denominator/common/Util.java // public static <T> T nextOrNull(Iterator<T> it) { // return it.hasNext() ? it.next() : null; // } // Path: dynect/src/main/java/denominator/dynect/DynECTResourceRecordSetApi.java import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.inject.Inject; import denominator.ResourceRecordSetApi; import denominator.dynect.DynECT.Record; import denominator.model.ResourceRecordSet; import feign.FeignException; import static denominator.common.Preconditions.checkArgument; import static denominator.common.Preconditions.checkNotNull; import static denominator.common.Util.nextOrNull; import static java.lang.String.format; public Iterator<ResourceRecordSet<?>> iterator() { try { return api.rrsets(zone).data; } catch (FeignException e) { if (e.getMessage().indexOf("NOT_FOUND") != -1) { throw new IllegalArgumentException("zone " + zone + " not found", e); } throw e; } } @Override public Iterator<ResourceRecordSet<?>> iterateByName(final String name) { checkNotNull(name, "name"); return emptyIteratorOn404(new Iterable<ResourceRecordSet<?>>() { public Iterator<ResourceRecordSet<?>> iterator() { return api.rrsetsInZoneByName(zone, name).data; } }); } @Override public ResourceRecordSet<?> getByNameAndType(final String name, final String type) { checkNotNull(name, "name"); checkNotNull(type, "type"); Iterator<ResourceRecordSet<?>> rrset = emptyIteratorOn404(new Iterable<ResourceRecordSet<?>>() { public Iterator<ResourceRecordSet<?>> iterator() { return api.rrsetsInZoneByNameAndType(zone, name, type).data; } });
return nextOrNull(rrset);
Netflix/denominator
ultradns/src/main/java/denominator/ultradns/UltraDNSErrorDecoder.java
// Path: model/src/main/java/denominator/common/Util.java // public static String slurp(Reader reader) throws IOException { // StringBuilder to = new StringBuilder(); // CharBuffer buf = CharBuffer.allocate(BUF_SIZE); // while (reader.read(buf) != -1) { // buf.flip(); // to.append(buf); // buf.clear(); // } // return to.toString(); // }
import org.xml.sax.helpers.DefaultHandler; import java.io.IOException; import javax.inject.Inject; import feign.FeignException; import feign.Response; import feign.RetryableException; import feign.codec.Decoder; import feign.codec.ErrorDecoder; import feign.sax.SAXDecoder.ContentHandlerWithResult; import static denominator.common.Util.slurp; import static feign.Util.UTF_8; import static java.lang.String.format;
package denominator.ultradns; class UltraDNSErrorDecoder implements ErrorDecoder { private final Decoder decoder; UltraDNSErrorDecoder(Decoder decoder) { this.decoder = decoder; } static Response bufferResponse(Response response) throws IOException { if (response.body() == null) { return response; }
// Path: model/src/main/java/denominator/common/Util.java // public static String slurp(Reader reader) throws IOException { // StringBuilder to = new StringBuilder(); // CharBuffer buf = CharBuffer.allocate(BUF_SIZE); // while (reader.read(buf) != -1) { // buf.flip(); // to.append(buf); // buf.clear(); // } // return to.toString(); // } // Path: ultradns/src/main/java/denominator/ultradns/UltraDNSErrorDecoder.java import org.xml.sax.helpers.DefaultHandler; import java.io.IOException; import javax.inject.Inject; import feign.FeignException; import feign.Response; import feign.RetryableException; import feign.codec.Decoder; import feign.codec.ErrorDecoder; import feign.sax.SAXDecoder.ContentHandlerWithResult; import static denominator.common.Util.slurp; import static feign.Util.UTF_8; import static java.lang.String.format; package denominator.ultradns; class UltraDNSErrorDecoder implements ErrorDecoder { private final Decoder decoder; UltraDNSErrorDecoder(Decoder decoder) { this.decoder = decoder; } static Response bufferResponse(Response response) throws IOException { if (response.body() == null) { return response; }
String body = slurp(response.body().asReader());
Netflix/denominator
core/src/main/java/denominator/CredentialsConfiguration.java
// Path: model/src/main/java/denominator/common/Util.java // public static String join(char delim, Object... parts) { // if (parts == null || parts.length == 0) { // return ""; // } // StringBuilder to = new StringBuilder(); // for (int i = 0; i < parts.length; i++) { // to.append(parts[i]); // if (i + 1 < parts.length) { // to.append(delim); // } // } // return to.toString(); // }
import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import dagger.Module; import dagger.Provides; import denominator.Credentials.AnonymousCredentials; import denominator.Credentials.ListCredentials; import static denominator.common.Preconditions.checkNotNull; import static denominator.common.Util.join;
Set<?> keys) { for (String credentialType : provider.credentialTypeToParameterNames().keySet()) { if (keys.containsAll(provider.credentialTypeToParameterNames().get(credentialType))) { return true; } } return false; } /** * Use this method to generate a consistent error message when the credentials supplied are not * valid for the provider. Typically, this will be the message of an {@code * IllegalArgumentException} * * @param input nullable credentials you know are invalid * @param provider provider they are invalid for */ public static String exceptionMessage(Credentials input, denominator.Provider provider) { StringBuilder msg = new StringBuilder(); if (input == null || input == AnonymousCredentials.INSTANCE) { msg.append("no credentials supplied. "); } else { msg.append("incorrect credentials supplied. "); } msg.append(provider.name()).append(" requires "); Map<String, Collection<String>> credentialTypeToParameterNames = provider.credentialTypeToParameterNames(); if (credentialTypeToParameterNames.size() == 1) {
// Path: model/src/main/java/denominator/common/Util.java // public static String join(char delim, Object... parts) { // if (parts == null || parts.length == 0) { // return ""; // } // StringBuilder to = new StringBuilder(); // for (int i = 0; i < parts.length; i++) { // to.append(parts[i]); // if (i + 1 < parts.length) { // to.append(delim); // } // } // return to.toString(); // } // Path: core/src/main/java/denominator/CredentialsConfiguration.java import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import dagger.Module; import dagger.Provides; import denominator.Credentials.AnonymousCredentials; import denominator.Credentials.ListCredentials; import static denominator.common.Preconditions.checkNotNull; import static denominator.common.Util.join; Set<?> keys) { for (String credentialType : provider.credentialTypeToParameterNames().keySet()) { if (keys.containsAll(provider.credentialTypeToParameterNames().get(credentialType))) { return true; } } return false; } /** * Use this method to generate a consistent error message when the credentials supplied are not * valid for the provider. Typically, this will be the message of an {@code * IllegalArgumentException} * * @param input nullable credentials you know are invalid * @param provider provider they are invalid for */ public static String exceptionMessage(Credentials input, denominator.Provider provider) { StringBuilder msg = new StringBuilder(); if (input == null || input == AnonymousCredentials.INSTANCE) { msg.append("no credentials supplied. "); } else { msg.append("incorrect credentials supplied. "); } msg.append(provider.name()).append(" requires "); Map<String, Collection<String>> credentialTypeToParameterNames = provider.credentialTypeToParameterNames(); if (credentialTypeToParameterNames.size() == 1) {
msg.append(join(',', credentialTypeToParameterNames.values().iterator().next().toArray()));
Netflix/denominator
model/src/test/java/denominator/common/UtilTest.java
// Path: model/src/main/java/denominator/model/rdata/TXTData.java // public final class TXTData extends LinkedHashMap<String, Object> { // // private static final long serialVersionUID = 1L; // // TXTData(String txtdata) { // checkArgument(checkNotNull(txtdata, "txtdata").length() <= 65535, // "txt data is limited to 65535"); // put("txtdata", txtdata); // } // // public static TXTData create(String txtdata) { // return new TXTData(txtdata); // } // // /** // * One or more character-strings. // * // * @since 1.3 // */ // public String txtdata() { // return get("txtdata").toString(); // } // } // // Path: model/src/main/java/denominator/common/Util.java // public static <T> Filter<T> and(final Filter<T> first, final Filter<? super T> second) { // checkNotNull(first, "first"); // checkNotNull(second, "second"); // return new Filter<T>() { // public boolean apply(T in) { // if (!first.apply(in)) { // return false; // } // return second.apply(in); // } // }; // } // // Path: model/src/main/java/denominator/common/Util.java // public static <T> Iterator<T> concat(final Iterator<T> first, final Iterator<T> second) { // checkNotNull(first, "first"); // checkNotNull(second, "second"); // return new PeekingIterator<T>() { // Iterator<? extends T> current = first; // // protected T computeNext() { // if (!current.hasNext() && current != second) { // current = second; // } // while (current.hasNext()) { // T element = current.next(); // if (element != null) { // return element; // } // } // return endOfData(); // } // }; // } // // Path: model/src/main/java/denominator/common/Util.java // public static boolean equal(Object a, Object b) { // return a == b || (a != null && a.equals(b)); // } // // Path: model/src/main/java/denominator/common/Util.java // public static <T> Iterator<T> filter(final Iterator<T> unfiltered, // final Filter<? super T> filter) { // checkNotNull(unfiltered, "unfiltered"); // checkNotNull(filter, "filter"); // return new PeekingIterator<T>() { // protected T computeNext() { // while (unfiltered.hasNext()) { // T element = unfiltered.next(); // if (filter.apply(element)) { // return element; // } // } // return endOfData(); // } // }; // } // // Path: model/src/main/java/denominator/common/Util.java // public static String join(char delim, Object... parts) { // if (parts == null || parts.length == 0) { // return ""; // } // StringBuilder to = new StringBuilder(); // for (int i = 0; i < parts.length; i++) { // to.append(parts[i]); // if (i + 1 < parts.length) { // to.append(delim); // } // } // return to.toString(); // } // // Path: model/src/main/java/denominator/common/Util.java // public static <T> T nextOrNull(Iterator<T> it) { // return it.hasNext() ? it.next() : null; // } // // Path: model/src/main/java/denominator/common/Util.java // public static <T> PeekingIterator<T> peekingIterator(final Iterator<T> iterator) { // checkNotNull(iterator, "iterator"); // return new PeekingIterator<T>() { // protected T computeNext() { // if (iterator.hasNext()) { // return iterator.next(); // } // return endOfData(); // } // }; // } // // Path: model/src/main/java/denominator/common/Util.java // public static String slurp(Reader reader) throws IOException { // StringBuilder to = new StringBuilder(); // CharBuffer buf = CharBuffer.allocate(BUF_SIZE); // while (reader.read(buf) != -1) { // buf.flip(); // to.append(buf); // buf.clear(); // } // return to.toString(); // } // // Path: model/src/main/java/denominator/common/Util.java // public static List<String> split(char delim, String toSplit) { // checkNotNull(toSplit, "toSplit"); // if (toSplit.indexOf(delim) == -1) { // return Arrays.asList(toSplit); // sortable in JRE 7 and 8 // } // List<String> out = new LinkedList<String>(); // StringBuilder currentString = new StringBuilder(); // for (char c : toSplit.toCharArray()) { // if (c == delim) { // out.add(emptyToNull(currentString.toString())); // currentString.setLength(0); // } else { // currentString.append(c); // } // } // out.add(emptyToNull(currentString.toString())); // return out; // }
import denominator.model.rdata.TXTData; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.IOException; import java.io.StringReader; import java.util.Arrays; import java.util.Iterator; import denominator.common.PeekingIteratorTest.TrueThenDone; import static denominator.common.Util.and; import static denominator.common.Util.concat; import static denominator.common.Util.equal; import static denominator.common.Util.filter; import static denominator.common.Util.join; import static denominator.common.Util.nextOrNull; import static denominator.common.Util.peekingIterator; import static denominator.common.Util.slurp; import static denominator.common.Util.split; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue;
package denominator.common; public class UtilTest { @Rule public final ExpectedException thrown = ExpectedException.none(); @Test public void slurpDoesntScrewWithWhitespance() throws IOException {
// Path: model/src/main/java/denominator/model/rdata/TXTData.java // public final class TXTData extends LinkedHashMap<String, Object> { // // private static final long serialVersionUID = 1L; // // TXTData(String txtdata) { // checkArgument(checkNotNull(txtdata, "txtdata").length() <= 65535, // "txt data is limited to 65535"); // put("txtdata", txtdata); // } // // public static TXTData create(String txtdata) { // return new TXTData(txtdata); // } // // /** // * One or more character-strings. // * // * @since 1.3 // */ // public String txtdata() { // return get("txtdata").toString(); // } // } // // Path: model/src/main/java/denominator/common/Util.java // public static <T> Filter<T> and(final Filter<T> first, final Filter<? super T> second) { // checkNotNull(first, "first"); // checkNotNull(second, "second"); // return new Filter<T>() { // public boolean apply(T in) { // if (!first.apply(in)) { // return false; // } // return second.apply(in); // } // }; // } // // Path: model/src/main/java/denominator/common/Util.java // public static <T> Iterator<T> concat(final Iterator<T> first, final Iterator<T> second) { // checkNotNull(first, "first"); // checkNotNull(second, "second"); // return new PeekingIterator<T>() { // Iterator<? extends T> current = first; // // protected T computeNext() { // if (!current.hasNext() && current != second) { // current = second; // } // while (current.hasNext()) { // T element = current.next(); // if (element != null) { // return element; // } // } // return endOfData(); // } // }; // } // // Path: model/src/main/java/denominator/common/Util.java // public static boolean equal(Object a, Object b) { // return a == b || (a != null && a.equals(b)); // } // // Path: model/src/main/java/denominator/common/Util.java // public static <T> Iterator<T> filter(final Iterator<T> unfiltered, // final Filter<? super T> filter) { // checkNotNull(unfiltered, "unfiltered"); // checkNotNull(filter, "filter"); // return new PeekingIterator<T>() { // protected T computeNext() { // while (unfiltered.hasNext()) { // T element = unfiltered.next(); // if (filter.apply(element)) { // return element; // } // } // return endOfData(); // } // }; // } // // Path: model/src/main/java/denominator/common/Util.java // public static String join(char delim, Object... parts) { // if (parts == null || parts.length == 0) { // return ""; // } // StringBuilder to = new StringBuilder(); // for (int i = 0; i < parts.length; i++) { // to.append(parts[i]); // if (i + 1 < parts.length) { // to.append(delim); // } // } // return to.toString(); // } // // Path: model/src/main/java/denominator/common/Util.java // public static <T> T nextOrNull(Iterator<T> it) { // return it.hasNext() ? it.next() : null; // } // // Path: model/src/main/java/denominator/common/Util.java // public static <T> PeekingIterator<T> peekingIterator(final Iterator<T> iterator) { // checkNotNull(iterator, "iterator"); // return new PeekingIterator<T>() { // protected T computeNext() { // if (iterator.hasNext()) { // return iterator.next(); // } // return endOfData(); // } // }; // } // // Path: model/src/main/java/denominator/common/Util.java // public static String slurp(Reader reader) throws IOException { // StringBuilder to = new StringBuilder(); // CharBuffer buf = CharBuffer.allocate(BUF_SIZE); // while (reader.read(buf) != -1) { // buf.flip(); // to.append(buf); // buf.clear(); // } // return to.toString(); // } // // Path: model/src/main/java/denominator/common/Util.java // public static List<String> split(char delim, String toSplit) { // checkNotNull(toSplit, "toSplit"); // if (toSplit.indexOf(delim) == -1) { // return Arrays.asList(toSplit); // sortable in JRE 7 and 8 // } // List<String> out = new LinkedList<String>(); // StringBuilder currentString = new StringBuilder(); // for (char c : toSplit.toCharArray()) { // if (c == delim) { // out.add(emptyToNull(currentString.toString())); // currentString.setLength(0); // } else { // currentString.append(c); // } // } // out.add(emptyToNull(currentString.toString())); // return out; // } // Path: model/src/test/java/denominator/common/UtilTest.java import denominator.model.rdata.TXTData; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.IOException; import java.io.StringReader; import java.util.Arrays; import java.util.Iterator; import denominator.common.PeekingIteratorTest.TrueThenDone; import static denominator.common.Util.and; import static denominator.common.Util.concat; import static denominator.common.Util.equal; import static denominator.common.Util.filter; import static denominator.common.Util.join; import static denominator.common.Util.nextOrNull; import static denominator.common.Util.peekingIterator; import static denominator.common.Util.slurp; import static denominator.common.Util.split; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; package denominator.common; public class UtilTest { @Rule public final ExpectedException thrown = ExpectedException.none(); @Test public void slurpDoesntScrewWithWhitespance() throws IOException {
assertThat(slurp(new StringReader(" foo\n"))).isEqualTo(" foo\n");
TrainerGuy22/Oceania
src/main/java/oceania/items/ItemBlockLimestone.java
// Path: src/main/java/oceania/blocks/BlockLimestone.java // public class BlockLimestone extends Block // { // // public enum LimestoneTypes // { // LIMESTONE("limestone", "Limestone"), // LIMESTONE_BRICK("limestoneBrick", "Limestone Brick"); // // private String _unloc, _loc; // private LimestoneTypes(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // // public BlockLimestone(int id) // { // super(id, Material.rock); // setCreativeTab(Oceania.CREATIVE_TAB); // this.setHardness(1.5F); // this.setResistance(10.0F); // this.setStepSound(soundStoneFootstep); // ItemBlockLimestone.registerDescription(this, "A mineral deposit, good for\ndecoration."); // } // // @Override // public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) // { // world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3); // } // // @Override // @SideOnly(Side.CLIENT) // public void registerIcons(IconRegister registry) // { // for(int index = 0; index < LimestoneTypes.values().length; index++) // { // IconRegistry.setIcon(LimestoneTypes.values()[index].getUnlocalizedName(), registry.registerIcon(Oceania.MOD_ID + ":" + LimestoneTypes.values()[index].getUnlocalizedName())); // } // } // // @Override // @SideOnly(Side.CLIENT) // public Icon getIcon(int side, int meta) // { // // Why do I have to put a modulus here? o_O // return IconRegistry.getIcon(LimestoneTypes.values()[meta % LimestoneTypes.values().length].getUnlocalizedName()); // } // // @Override // public int damageDropped(int meta) // { // return meta; // } // // } // // Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // }
import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import oceania.blocks.BlockLimestone; import oceania.items.ItemMulti.ItemMultiType; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package oceania.items; public class ItemBlockLimestone extends ItemBlockWithDescription { public ItemBlockLimestone(int itemID) { super(itemID); this.hasSubtypes = true;
// Path: src/main/java/oceania/blocks/BlockLimestone.java // public class BlockLimestone extends Block // { // // public enum LimestoneTypes // { // LIMESTONE("limestone", "Limestone"), // LIMESTONE_BRICK("limestoneBrick", "Limestone Brick"); // // private String _unloc, _loc; // private LimestoneTypes(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // // public BlockLimestone(int id) // { // super(id, Material.rock); // setCreativeTab(Oceania.CREATIVE_TAB); // this.setHardness(1.5F); // this.setResistance(10.0F); // this.setStepSound(soundStoneFootstep); // ItemBlockLimestone.registerDescription(this, "A mineral deposit, good for\ndecoration."); // } // // @Override // public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) // { // world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3); // } // // @Override // @SideOnly(Side.CLIENT) // public void registerIcons(IconRegister registry) // { // for(int index = 0; index < LimestoneTypes.values().length; index++) // { // IconRegistry.setIcon(LimestoneTypes.values()[index].getUnlocalizedName(), registry.registerIcon(Oceania.MOD_ID + ":" + LimestoneTypes.values()[index].getUnlocalizedName())); // } // } // // @Override // @SideOnly(Side.CLIENT) // public Icon getIcon(int side, int meta) // { // // Why do I have to put a modulus here? o_O // return IconRegistry.getIcon(LimestoneTypes.values()[meta % LimestoneTypes.values().length].getUnlocalizedName()); // } // // @Override // public int damageDropped(int meta) // { // return meta; // } // // } // // Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // Path: src/main/java/oceania/items/ItemBlockLimestone.java import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import oceania.blocks.BlockLimestone; import oceania.items.ItemMulti.ItemMultiType; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package oceania.items; public class ItemBlockLimestone extends ItemBlockWithDescription { public ItemBlockLimestone(int itemID) { super(itemID); this.hasSubtypes = true;
for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values())
TrainerGuy22/Oceania
src/main/java/oceania/blocks/BlockAtlantiteOre.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockWithDescription.java // public class ItemBlockWithDescription extends ItemBlock // { // private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); // // public static void registerDescription(Block block, String description) // { // descriptions.put(block.blockID, description); // } // // public ItemBlockWithDescription(int itemID) // { // super(itemID); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) // { // if (descriptions.containsKey((Integer) itemStack.itemID)) // { // if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) // { // String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); // for (String line : lines) // { // descriptionList.add(line); // } // } // else // { // descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); // } // } // } // }
import java.util.Random; import oceania.Oceania; import oceania.items.ItemBlockWithDescription; import oceania.items.Items; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister;
package oceania.blocks; public class BlockAtlantiteOre extends Block { public BlockAtlantiteOre() { super(blockID, Material.sand); setHardness(2.8f); setResistance(8f); setStepSound(soundSandFootstep); setUnlocalizedName("blockAtlantite");
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockWithDescription.java // public class ItemBlockWithDescription extends ItemBlock // { // private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); // // public static void registerDescription(Block block, String description) // { // descriptions.put(block.blockID, description); // } // // public ItemBlockWithDescription(int itemID) // { // super(itemID); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) // { // if (descriptions.containsKey((Integer) itemStack.itemID)) // { // if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) // { // String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); // for (String line : lines) // { // descriptionList.add(line); // } // } // else // { // descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); // } // } // } // } // Path: src/main/java/oceania/blocks/BlockAtlantiteOre.java import java.util.Random; import oceania.Oceania; import oceania.items.ItemBlockWithDescription; import oceania.items.Items; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; package oceania.blocks; public class BlockAtlantiteOre extends Block { public BlockAtlantiteOre() { super(blockID, Material.sand); setHardness(2.8f); setResistance(8f); setStepSound(soundSandFootstep); setUnlocalizedName("blockAtlantite");
setCreativeTab(Oceania.CREATIVE_TAB);
TrainerGuy22/Oceania
src/main/java/oceania/blocks/BlockAtlantiteOre.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockWithDescription.java // public class ItemBlockWithDescription extends ItemBlock // { // private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); // // public static void registerDescription(Block block, String description) // { // descriptions.put(block.blockID, description); // } // // public ItemBlockWithDescription(int itemID) // { // super(itemID); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) // { // if (descriptions.containsKey((Integer) itemStack.itemID)) // { // if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) // { // String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); // for (String line : lines) // { // descriptionList.add(line); // } // } // else // { // descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); // } // } // } // }
import java.util.Random; import oceania.Oceania; import oceania.items.ItemBlockWithDescription; import oceania.items.Items; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister;
package oceania.blocks; public class BlockAtlantiteOre extends Block { public BlockAtlantiteOre() { super(blockID, Material.sand); setHardness(2.8f); setResistance(8f); setStepSound(soundSandFootstep); setUnlocalizedName("blockAtlantite"); setCreativeTab(Oceania.CREATIVE_TAB);
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockWithDescription.java // public class ItemBlockWithDescription extends ItemBlock // { // private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); // // public static void registerDescription(Block block, String description) // { // descriptions.put(block.blockID, description); // } // // public ItemBlockWithDescription(int itemID) // { // super(itemID); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) // { // if (descriptions.containsKey((Integer) itemStack.itemID)) // { // if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) // { // String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); // for (String line : lines) // { // descriptionList.add(line); // } // } // else // { // descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); // } // } // } // } // Path: src/main/java/oceania/blocks/BlockAtlantiteOre.java import java.util.Random; import oceania.Oceania; import oceania.items.ItemBlockWithDescription; import oceania.items.Items; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; package oceania.blocks; public class BlockAtlantiteOre extends Block { public BlockAtlantiteOre() { super(blockID, Material.sand); setHardness(2.8f); setResistance(8f); setStepSound(soundSandFootstep); setUnlocalizedName("blockAtlantite"); setCreativeTab(Oceania.CREATIVE_TAB);
ItemBlockWithDescription.registerDescription(this, "Some sort of naturally occuring\nalloy...");
TrainerGuy22/Oceania
src/main/java/oceania/entity/EntityOceaniaBoatNormal.java
// Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // }
import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.world.World; import oceania.items.ItemMulti.ItemMultiType; import oceania.items.Items;
{ return 1.5f; } @Override public float getBoatHeight() { return 0.6f; } @Override public float getMaxSpeed() { return 0.35f + ((float) getBoatType().ordinal() * 0.05f); } @Override public double getMountedYOffset() { return 1.0f; } @SuppressWarnings("incomplete-switch") @Override public void dropItemsOnDeath() { switch (getBoatType()) { case ATLANTIUM: EntityItem item = this.dropItem(Items.itemMulti.itemID, 5);
// Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // Path: src/main/java/oceania/entity/EntityOceaniaBoatNormal.java import net.minecraft.block.Block; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.world.World; import oceania.items.ItemMulti.ItemMultiType; import oceania.items.Items; { return 1.5f; } @Override public float getBoatHeight() { return 0.6f; } @Override public float getMaxSpeed() { return 0.35f + ((float) getBoatType().ordinal() * 0.05f); } @Override public double getMountedYOffset() { return 1.0f; } @SuppressWarnings("incomplete-switch") @Override public void dropItemsOnDeath() { switch (getBoatType()) { case ATLANTIUM: EntityItem item = this.dropItem(Items.itemMulti.itemID, 5);
item.getEntityItem().setItemDamage(ItemMultiType.ATLANTIUM.ordinal());
TrainerGuy22/Oceania
src/main/java/oceania/entity/EntitySubmarine.java
// Path: src/main/java/oceania/util/DataWatcherTypes.java // public enum DataWatcherTypes { // BYTE, // SHORT, // INTEGER, // FLOAT, // STRING, // ITEMSTACK, // CHUNKCOORDINATES; // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import oceania.items.Items; import oceania.util.DataWatcherTypes; import oceania.util.OUtil; import cpw.mods.fml.relauncher.Side;
private Entity lastRidingEntity; public EntitySubmarine(World world) { super(world); this.boundingBox.maxX = this.boundingBox.minX + 3.0f; this.boundingBox.maxY = this.boundingBox.minY + 2.35f; this.boundingBox.maxZ = this.boundingBox.minZ + 4.0f; this.ignoreFrustumCheck = true; this.waterOffset = -2.0f; this.lastRidingEntity = null; } public EntitySubmarine(World world, double x, double y, double z) { this(world); this.setPosition(x, y + (double) yOffset, z); this.setPreviousPosition(x, y, z); } @Override public double getMountedYOffset() { return 1.5f; } @Override public boolean interactFirst(EntityPlayer player) { boolean superResult = super.interactFirst(player);
// Path: src/main/java/oceania/util/DataWatcherTypes.java // public enum DataWatcherTypes { // BYTE, // SHORT, // INTEGER, // FLOAT, // STRING, // ITEMSTACK, // CHUNKCOORDINATES; // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/entity/EntitySubmarine.java import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import oceania.items.Items; import oceania.util.DataWatcherTypes; import oceania.util.OUtil; import cpw.mods.fml.relauncher.Side; private Entity lastRidingEntity; public EntitySubmarine(World world) { super(world); this.boundingBox.maxX = this.boundingBox.minX + 3.0f; this.boundingBox.maxY = this.boundingBox.minY + 2.35f; this.boundingBox.maxZ = this.boundingBox.minZ + 4.0f; this.ignoreFrustumCheck = true; this.waterOffset = -2.0f; this.lastRidingEntity = null; } public EntitySubmarine(World world, double x, double y, double z) { this(world); this.setPosition(x, y + (double) yOffset, z); this.setPreviousPosition(x, y, z); } @Override public double getMountedYOffset() { return 1.5f; } @Override public boolean interactFirst(EntityPlayer player) { boolean superResult = super.interactFirst(player);
if (OUtil.getSide() == Side.CLIENT)
TrainerGuy22/Oceania
src/main/java/oceania/entity/EntitySubmarine.java
// Path: src/main/java/oceania/util/DataWatcherTypes.java // public enum DataWatcherTypes { // BYTE, // SHORT, // INTEGER, // FLOAT, // STRING, // ITEMSTACK, // CHUNKCOORDINATES; // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import oceania.items.Items; import oceania.util.DataWatcherTypes; import oceania.util.OUtil; import cpw.mods.fml.relauncher.Side;
{ this(world); this.setPosition(x, y + (double) yOffset, z); this.setPreviousPosition(x, y, z); } @Override public double getMountedYOffset() { return 1.5f; } @Override public boolean interactFirst(EntityPlayer player) { boolean superResult = super.interactFirst(player); if (OUtil.getSide() == Side.CLIENT) { GameSettings settings = Minecraft.getMinecraft().gameSettings; this.dataWatcher.updateObject(INDEX_GAMMA, settings.gammaSetting); settings.gammaSetting = 10.0f; } return superResult; } @Override protected void entityInit() { super.entityInit();
// Path: src/main/java/oceania/util/DataWatcherTypes.java // public enum DataWatcherTypes { // BYTE, // SHORT, // INTEGER, // FLOAT, // STRING, // ITEMSTACK, // CHUNKCOORDINATES; // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/entity/EntitySubmarine.java import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import oceania.items.Items; import oceania.util.DataWatcherTypes; import oceania.util.OUtil; import cpw.mods.fml.relauncher.Side; { this(world); this.setPosition(x, y + (double) yOffset, z); this.setPreviousPosition(x, y, z); } @Override public double getMountedYOffset() { return 1.5f; } @Override public boolean interactFirst(EntityPlayer player) { boolean superResult = super.interactFirst(player); if (OUtil.getSide() == Side.CLIENT) { GameSettings settings = Minecraft.getMinecraft().gameSettings; this.dataWatcher.updateObject(INDEX_GAMMA, settings.gammaSetting); settings.gammaSetting = 10.0f; } return superResult; } @Override protected void entityInit() { super.entityInit();
this.dataWatcher.addObjectByDataType(INDEX_GAMMA, DataWatcherTypes.FLOAT.ordinal());
TrainerGuy22/Oceania
src/main/java/oceania/items/ItemDivingHelmet.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import java.util.ArrayList; import java.util.List; import org.lwjgl.input.Keyboard; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; import oceania.Oceania; import oceania.util.OUtil; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package oceania.items; public class ItemDivingHelmet extends ItemArmor implements ISpecialArmor { private ArmorProperties _armorProperties; public ItemDivingHelmet(int itemID) { super(itemID, EnumArmorMaterial.IRON, 2, 0);
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/items/ItemDivingHelmet.java import java.util.ArrayList; import java.util.List; import org.lwjgl.input.Keyboard; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; import oceania.Oceania; import oceania.util.OUtil; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package oceania.items; public class ItemDivingHelmet extends ItemArmor implements ISpecialArmor { private ArmorProperties _armorProperties; public ItemDivingHelmet(int itemID) { super(itemID, EnumArmorMaterial.IRON, 2, 0);
setCreativeTab(Oceania.CREATIVE_TAB);
TrainerGuy22/Oceania
src/main/java/oceania/items/ItemDivingHelmet.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import java.util.ArrayList; import java.util.List; import org.lwjgl.input.Keyboard; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; import oceania.Oceania; import oceania.util.OUtil; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
* @param entity * The entity wearing the armor * @param stack * The ItemStack of the armor item itself. * @param source * The source of the damage, which can be used to alter armor * properties based on the type or source of damage. * @param damage * The amount of damage being applied to the armor * @param slot * The armor slot the item is in. */ @Override public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { stack.damageItem(damage, entity); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { descriptionList.add("Allows the wearer to see underwater."); descriptionList.add("Also allows wearer to breathe slightly"); descriptionList.add("longer while underwater."); } else {
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/items/ItemDivingHelmet.java import java.util.ArrayList; import java.util.List; import org.lwjgl.input.Keyboard; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumArmorMaterial; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; import oceania.Oceania; import oceania.util.OUtil; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; * @param entity * The entity wearing the armor * @param stack * The ItemStack of the armor item itself. * @param source * The source of the damage, which can be used to alter armor * properties based on the type or source of damage. * @param damage * The amount of damage being applied to the armor * @param slot * The armor slot the item is in. */ @Override public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { stack.damageItem(damage, entity); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { descriptionList.add("Allows the wearer to see underwater."); descriptionList.add("Also allows wearer to breathe slightly"); descriptionList.add("longer while underwater."); } else {
descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information"));
TrainerGuy22/Oceania
src/main/java/oceania/blocks/tile/TileEntityAtlantiumDepulsor.java
// Path: src/main/java/oceania/blocks/Blocks.java // public class Blocks // { // public static final int DEFAULT_ID_RANGE = 375; // // public static BlockAtlantiteOre blockAtlantite; // public static BlockAtlantiumDepulsor blockDepulsor; // public static BlockDepulsorPlaceholder blockPlaceholder; // public static BlockLimestone blockLimestone; // public static BlockLimestonePillar blockLimestonePillar; // public static BlockChestSpawner blockChestSpawner; // // public static void initBlocks() // { // Configuration cfg = Oceania.CONFIG; // // /** Set up instances */ // blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); // blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); // blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); // blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); // // /** Add to registry */ // GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite"); // GameRegistry.registerBlock(blockDepulsor, ItemBlockWithDescription.class, "blockDepulsor"); // GameRegistry.registerBlock(blockLimestone, ItemBlockLimestone.class, "blockLimestone"); // GameRegistry.registerBlock(blockLimestonePillar, ItemBlockWithDescription.class, "blockLimestonePillar"); // GameRegistry.registerBlock(blockPlaceholder, "blockDepulsorPlaceholder"); // GameRegistry.registerBlock(blockChestSpawner, ItemBlockWithDescription.class, "blockChestSpawner"); // // /** Add language */ // LanguageRegistry.addName(blockAtlantite, "Atlantite Ore"); // LanguageRegistry.addName(blockDepulsor, "Atlantium Depulsor"); // LanguageRegistry.addName(blockLimestonePillar, "Limestone Pillar"); // LanguageRegistry.addName(blockChestSpawner, "Chest Spawner"); // } // }
import oceania.blocks.Blocks; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity;
package oceania.blocks.tile; public class TileEntityAtlantiumDepulsor extends TileEntity { // Holds 32 Ender Pearls at a time, or 2 stacks. public int enderPearls = 0; // Each Ender Pearl lasts for half a Minecraft day. public int TIME_LEFT = 0; public TileEntityAtlantiumDepulsor() {} @Override public void updateEntity() { if(TIME_LEFT != 0) { int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); int radius = meta / 4; for (int xx = xCoord - radius; xx <= xCoord + radius; xx++) { for (int yy = yCoord - radius; yy <= yCoord + radius; yy++) { for (int zz = zCoord - radius; zz <= zCoord + radius; zz++) { int bID = worldObj.getBlockId(xx, yy, zz); if (bID == Block.waterMoving.blockID || bID == Block.waterStill.blockID || bID == 0) {
// Path: src/main/java/oceania/blocks/Blocks.java // public class Blocks // { // public static final int DEFAULT_ID_RANGE = 375; // // public static BlockAtlantiteOre blockAtlantite; // public static BlockAtlantiumDepulsor blockDepulsor; // public static BlockDepulsorPlaceholder blockPlaceholder; // public static BlockLimestone blockLimestone; // public static BlockLimestonePillar blockLimestonePillar; // public static BlockChestSpawner blockChestSpawner; // // public static void initBlocks() // { // Configuration cfg = Oceania.CONFIG; // // /** Set up instances */ // blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); // blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); // blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); // blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); // // /** Add to registry */ // GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite"); // GameRegistry.registerBlock(blockDepulsor, ItemBlockWithDescription.class, "blockDepulsor"); // GameRegistry.registerBlock(blockLimestone, ItemBlockLimestone.class, "blockLimestone"); // GameRegistry.registerBlock(blockLimestonePillar, ItemBlockWithDescription.class, "blockLimestonePillar"); // GameRegistry.registerBlock(blockPlaceholder, "blockDepulsorPlaceholder"); // GameRegistry.registerBlock(blockChestSpawner, ItemBlockWithDescription.class, "blockChestSpawner"); // // /** Add language */ // LanguageRegistry.addName(blockAtlantite, "Atlantite Ore"); // LanguageRegistry.addName(blockDepulsor, "Atlantium Depulsor"); // LanguageRegistry.addName(blockLimestonePillar, "Limestone Pillar"); // LanguageRegistry.addName(blockChestSpawner, "Chest Spawner"); // } // } // Path: src/main/java/oceania/blocks/tile/TileEntityAtlantiumDepulsor.java import oceania.blocks.Blocks; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; package oceania.blocks.tile; public class TileEntityAtlantiumDepulsor extends TileEntity { // Holds 32 Ender Pearls at a time, or 2 stacks. public int enderPearls = 0; // Each Ender Pearl lasts for half a Minecraft day. public int TIME_LEFT = 0; public TileEntityAtlantiumDepulsor() {} @Override public void updateEntity() { if(TIME_LEFT != 0) { int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); int radius = meta / 4; for (int xx = xCoord - radius; xx <= xCoord + radius; xx++) { for (int yy = yCoord - radius; yy <= yCoord + radius; yy++) { for (int zz = zCoord - radius; zz <= zCoord + radius; zz++) { int bID = worldObj.getBlockId(xx, yy, zz); if (bID == Block.waterMoving.blockID || bID == Block.waterStill.blockID || bID == 0) {
worldObj.setBlock(xx, yy, zz, Blocks.blockPlaceholder.blockID);
TrainerGuy22/Oceania
src/main/java/oceania/util/BoatType.java
// Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // }
import oceania.items.ItemMulti.ItemMultiType; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation;
package oceania.util; public enum BoatType { WOOD("minecraft", "boat", "Wooden Boat", new ResourceLocation("textures/entity/boat.png"), new ItemStack(Items.stick), 20), IRON("oceania", "ironBoat", "Iron Boat", new ResourceLocation("oceania", "textures/models/ironBoat.png"), new ItemStack(Items.iron_ingot), 75),
// Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // Path: src/main/java/oceania/util/BoatType.java import oceania.items.ItemMulti.ItemMultiType; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; package oceania.util; public enum BoatType { WOOD("minecraft", "boat", "Wooden Boat", new ResourceLocation("textures/entity/boat.png"), new ItemStack(Items.stick), 20), IRON("oceania", "ironBoat", "Iron Boat", new ResourceLocation("oceania", "textures/models/ironBoat.png"), new ItemStack(Items.iron_ingot), 75),
ATLANTIUM("oceania", "atlantiumBoat", "Atlantium Boat", new ResourceLocation("oceania", "textures/models/atlantiumBoat.png"), new ItemStack(Items.itemMulti, 1, ItemMultiType.ATLANTIUM.ordinal()), 450),
TrainerGuy22/Oceania
src/main/java/oceania/blocks/tile/TileEntityChestSpawner.java
// Path: src/main/java/oceania/blocks/Blocks.java // public class Blocks // { // public static final int DEFAULT_ID_RANGE = 375; // // public static BlockAtlantiteOre blockAtlantite; // public static BlockAtlantiumDepulsor blockDepulsor; // public static BlockDepulsorPlaceholder blockPlaceholder; // public static BlockLimestone blockLimestone; // public static BlockLimestonePillar blockLimestonePillar; // public static BlockChestSpawner blockChestSpawner; // // public static void initBlocks() // { // Configuration cfg = Oceania.CONFIG; // // /** Set up instances */ // blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); // blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); // blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); // blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); // // /** Add to registry */ // GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite"); // GameRegistry.registerBlock(blockDepulsor, ItemBlockWithDescription.class, "blockDepulsor"); // GameRegistry.registerBlock(blockLimestone, ItemBlockLimestone.class, "blockLimestone"); // GameRegistry.registerBlock(blockLimestonePillar, ItemBlockWithDescription.class, "blockLimestonePillar"); // GameRegistry.registerBlock(blockPlaceholder, "blockDepulsorPlaceholder"); // GameRegistry.registerBlock(blockChestSpawner, ItemBlockWithDescription.class, "blockChestSpawner"); // // /** Add language */ // LanguageRegistry.addName(blockAtlantite, "Atlantite Ore"); // LanguageRegistry.addName(blockDepulsor, "Atlantium Depulsor"); // LanguageRegistry.addName(blockLimestonePillar, "Limestone Pillar"); // LanguageRegistry.addName(blockChestSpawner, "Chest Spawner"); // } // } // // Path: src/main/java/oceania/entity/Entities.java // public class Entities // { // // public static int VILLAGER_OCEANIA_ID; // // public static void initEntities() // { // EntityRegistry.registerModEntity(EntityOceaniaBoatNormal.class, "OceaniaBoat", 0, Oceania.INSTANCE, 80, 3, true); // EntityRegistry.registerModEntity(EntityOceaniaBoatWithChest.class, "OceaniaBoatWithChest", 1, Oceania.INSTANCE, 80, 3, true); // EntityRegistry.registerModEntity(EntitySubmarine.class, "Submarine", 2, Oceania.INSTANCE, 80, 3, true); // // VILLAGER_OCEANIA_ID = VillagerRegistry.getRegisteredVillagers().size(); // VillagerRegistry.instance().registerVillagerId(VILLAGER_OCEANIA_ID); // // TODO: Post ModJam - Have a custom skin for the villager. // if (OUtil.getSide() == Side.CLIENT) // VillagerRegistry.instance().registerVillagerSkin(VILLAGER_OCEANIA_ID, new ResourceLocation("textures/entity/villager/smith.png")); // VillagerRegistry.instance().registerVillageTradeHandler(VILLAGER_OCEANIA_ID, new VillageTradeHandler()); // } // // }
import java.util.List; import java.util.Random; import oceania.blocks.Blocks; import oceania.entity.Entities; import oceania.items.Items; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingData; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection;
{ super(); } @Override public void updateEntity() { if(cooldown != 0 && !worldObj.isRemote) cooldown--; List<EntityVillager> villagers = this.worldObj.getEntitiesWithinAABB(EntityVillager.class, AxisAlignedBB.getBoundingBox(xCoord - maxRange, yCoord - 1 - maxRange, zCoord - maxRange, xCoord + 1 + maxRange, yCoord + 1 + maxRange, zCoord + maxRange)); int villagerCount = 0; for(EntityVillager villager : villagers) { villagerCount++; } if(villagerCount < 4 && cooldown < 1 && !this.worldObj.isRemote) { boolean triggered = false; int x = this.worldObj.rand.nextInt(maxRange * 2) - maxRange; int z = this.worldObj.rand.nextInt(maxRange * 2) - maxRange; while(x > (minRange * -1) - 1 && z < minRange + 1 && z < (minRange * -1) - 1 && z < minRange + 1) { x = this.worldObj.rand.nextInt(maxRange * 2) - maxRange; z = this.worldObj.rand.nextInt(maxRange * 2) - maxRange; } if(this.worldObj.rand.nextInt(4) == 3 && !triggered) { boolean valid = false; if(x <= 0)
// Path: src/main/java/oceania/blocks/Blocks.java // public class Blocks // { // public static final int DEFAULT_ID_RANGE = 375; // // public static BlockAtlantiteOre blockAtlantite; // public static BlockAtlantiumDepulsor blockDepulsor; // public static BlockDepulsorPlaceholder blockPlaceholder; // public static BlockLimestone blockLimestone; // public static BlockLimestonePillar blockLimestonePillar; // public static BlockChestSpawner blockChestSpawner; // // public static void initBlocks() // { // Configuration cfg = Oceania.CONFIG; // // /** Set up instances */ // blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); // blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); // blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); // blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); // // /** Add to registry */ // GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite"); // GameRegistry.registerBlock(blockDepulsor, ItemBlockWithDescription.class, "blockDepulsor"); // GameRegistry.registerBlock(blockLimestone, ItemBlockLimestone.class, "blockLimestone"); // GameRegistry.registerBlock(blockLimestonePillar, ItemBlockWithDescription.class, "blockLimestonePillar"); // GameRegistry.registerBlock(blockPlaceholder, "blockDepulsorPlaceholder"); // GameRegistry.registerBlock(blockChestSpawner, ItemBlockWithDescription.class, "blockChestSpawner"); // // /** Add language */ // LanguageRegistry.addName(blockAtlantite, "Atlantite Ore"); // LanguageRegistry.addName(blockDepulsor, "Atlantium Depulsor"); // LanguageRegistry.addName(blockLimestonePillar, "Limestone Pillar"); // LanguageRegistry.addName(blockChestSpawner, "Chest Spawner"); // } // } // // Path: src/main/java/oceania/entity/Entities.java // public class Entities // { // // public static int VILLAGER_OCEANIA_ID; // // public static void initEntities() // { // EntityRegistry.registerModEntity(EntityOceaniaBoatNormal.class, "OceaniaBoat", 0, Oceania.INSTANCE, 80, 3, true); // EntityRegistry.registerModEntity(EntityOceaniaBoatWithChest.class, "OceaniaBoatWithChest", 1, Oceania.INSTANCE, 80, 3, true); // EntityRegistry.registerModEntity(EntitySubmarine.class, "Submarine", 2, Oceania.INSTANCE, 80, 3, true); // // VILLAGER_OCEANIA_ID = VillagerRegistry.getRegisteredVillagers().size(); // VillagerRegistry.instance().registerVillagerId(VILLAGER_OCEANIA_ID); // // TODO: Post ModJam - Have a custom skin for the villager. // if (OUtil.getSide() == Side.CLIENT) // VillagerRegistry.instance().registerVillagerSkin(VILLAGER_OCEANIA_ID, new ResourceLocation("textures/entity/villager/smith.png")); // VillagerRegistry.instance().registerVillageTradeHandler(VILLAGER_OCEANIA_ID, new VillageTradeHandler()); // } // // } // Path: src/main/java/oceania/blocks/tile/TileEntityChestSpawner.java import java.util.List; import java.util.Random; import oceania.blocks.Blocks; import oceania.entity.Entities; import oceania.items.Items; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingData; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; { super(); } @Override public void updateEntity() { if(cooldown != 0 && !worldObj.isRemote) cooldown--; List<EntityVillager> villagers = this.worldObj.getEntitiesWithinAABB(EntityVillager.class, AxisAlignedBB.getBoundingBox(xCoord - maxRange, yCoord - 1 - maxRange, zCoord - maxRange, xCoord + 1 + maxRange, yCoord + 1 + maxRange, zCoord + maxRange)); int villagerCount = 0; for(EntityVillager villager : villagers) { villagerCount++; } if(villagerCount < 4 && cooldown < 1 && !this.worldObj.isRemote) { boolean triggered = false; int x = this.worldObj.rand.nextInt(maxRange * 2) - maxRange; int z = this.worldObj.rand.nextInt(maxRange * 2) - maxRange; while(x > (minRange * -1) - 1 && z < minRange + 1 && z < (minRange * -1) - 1 && z < minRange + 1) { x = this.worldObj.rand.nextInt(maxRange * 2) - maxRange; z = this.worldObj.rand.nextInt(maxRange * 2) - maxRange; } if(this.worldObj.rand.nextInt(4) == 3 && !triggered) { boolean valid = false; if(x <= 0)
valid = this.worldObj.getBlockId(xCoord + 1 + x, yCoord - 2, zCoord + z) == 0 || this.worldObj.getBlockId(xCoord + 1 + x, yCoord - 2, zCoord + z) == Blocks.blockPlaceholder.blockID;
TrainerGuy22/Oceania
src/main/java/oceania/blocks/Blocks.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemBlockWithDescription.java // public class ItemBlockWithDescription extends ItemBlock // { // private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); // // public static void registerDescription(Block block, String description) // { // descriptions.put(block.blockID, description); // } // // public ItemBlockWithDescription(int itemID) // { // super(itemID); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) // { // if (descriptions.containsKey((Integer) itemStack.itemID)) // { // if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) // { // String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); // for (String line : lines) // { // descriptionList.add(line); // } // } // else // { // descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); // } // } // } // }
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraftforge.common.Configuration; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.ItemBlockWithDescription;
package oceania.blocks; public class Blocks { public static final int DEFAULT_ID_RANGE = 375; public static BlockAtlantiteOre blockAtlantite; public static BlockAtlantiumDepulsor blockDepulsor; public static BlockDepulsorPlaceholder blockPlaceholder; public static BlockLimestone blockLimestone; public static BlockLimestonePillar blockLimestonePillar; public static BlockChestSpawner blockChestSpawner; public static void initBlocks() {
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemBlockWithDescription.java // public class ItemBlockWithDescription extends ItemBlock // { // private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); // // public static void registerDescription(Block block, String description) // { // descriptions.put(block.blockID, description); // } // // public ItemBlockWithDescription(int itemID) // { // super(itemID); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) // { // if (descriptions.containsKey((Integer) itemStack.itemID)) // { // if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) // { // String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); // for (String line : lines) // { // descriptionList.add(line); // } // } // else // { // descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); // } // } // } // } // Path: src/main/java/oceania/blocks/Blocks.java import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraftforge.common.Configuration; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.ItemBlockWithDescription; package oceania.blocks; public class Blocks { public static final int DEFAULT_ID_RANGE = 375; public static BlockAtlantiteOre blockAtlantite; public static BlockAtlantiumDepulsor blockDepulsor; public static BlockDepulsorPlaceholder blockPlaceholder; public static BlockLimestone blockLimestone; public static BlockLimestonePillar blockLimestonePillar; public static BlockChestSpawner blockChestSpawner; public static void initBlocks() {
Configuration cfg = Oceania.CONFIG;
TrainerGuy22/Oceania
src/main/java/oceania/blocks/Blocks.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemBlockWithDescription.java // public class ItemBlockWithDescription extends ItemBlock // { // private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); // // public static void registerDescription(Block block, String description) // { // descriptions.put(block.blockID, description); // } // // public ItemBlockWithDescription(int itemID) // { // super(itemID); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) // { // if (descriptions.containsKey((Integer) itemStack.itemID)) // { // if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) // { // String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); // for (String line : lines) // { // descriptionList.add(line); // } // } // else // { // descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); // } // } // } // }
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraftforge.common.Configuration; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.ItemBlockWithDescription;
package oceania.blocks; public class Blocks { public static final int DEFAULT_ID_RANGE = 375; public static BlockAtlantiteOre blockAtlantite; public static BlockAtlantiumDepulsor blockDepulsor; public static BlockDepulsorPlaceholder blockPlaceholder; public static BlockLimestone blockLimestone; public static BlockLimestonePillar blockLimestonePillar; public static BlockChestSpawner blockChestSpawner; public static void initBlocks() { Configuration cfg = Oceania.CONFIG; /** Set up instances */ blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); /** Add to registry */
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemBlockWithDescription.java // public class ItemBlockWithDescription extends ItemBlock // { // private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); // // public static void registerDescription(Block block, String description) // { // descriptions.put(block.blockID, description); // } // // public ItemBlockWithDescription(int itemID) // { // super(itemID); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) // { // if (descriptions.containsKey((Integer) itemStack.itemID)) // { // if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) // { // String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); // for (String line : lines) // { // descriptionList.add(line); // } // } // else // { // descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); // } // } // } // } // Path: src/main/java/oceania/blocks/Blocks.java import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraftforge.common.Configuration; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.ItemBlockWithDescription; package oceania.blocks; public class Blocks { public static final int DEFAULT_ID_RANGE = 375; public static BlockAtlantiteOre blockAtlantite; public static BlockAtlantiumDepulsor blockDepulsor; public static BlockDepulsorPlaceholder blockPlaceholder; public static BlockLimestone blockLimestone; public static BlockLimestonePillar blockLimestonePillar; public static BlockChestSpawner blockChestSpawner; public static void initBlocks() { Configuration cfg = Oceania.CONFIG; /** Set up instances */ blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); /** Add to registry */
GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite");
TrainerGuy22/Oceania
src/main/java/oceania/blocks/Blocks.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemBlockWithDescription.java // public class ItemBlockWithDescription extends ItemBlock // { // private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); // // public static void registerDescription(Block block, String description) // { // descriptions.put(block.blockID, description); // } // // public ItemBlockWithDescription(int itemID) // { // super(itemID); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) // { // if (descriptions.containsKey((Integer) itemStack.itemID)) // { // if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) // { // String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); // for (String line : lines) // { // descriptionList.add(line); // } // } // else // { // descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); // } // } // } // }
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraftforge.common.Configuration; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.ItemBlockWithDescription;
package oceania.blocks; public class Blocks { public static final int DEFAULT_ID_RANGE = 375; public static BlockAtlantiteOre blockAtlantite; public static BlockAtlantiumDepulsor blockDepulsor; public static BlockDepulsorPlaceholder blockPlaceholder; public static BlockLimestone blockLimestone; public static BlockLimestonePillar blockLimestonePillar; public static BlockChestSpawner blockChestSpawner; public static void initBlocks() { Configuration cfg = Oceania.CONFIG; /** Set up instances */ blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); /** Add to registry */ GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite"); GameRegistry.registerBlock(blockDepulsor, ItemBlockWithDescription.class, "blockDepulsor");
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemBlockWithDescription.java // public class ItemBlockWithDescription extends ItemBlock // { // private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); // // public static void registerDescription(Block block, String description) // { // descriptions.put(block.blockID, description); // } // // public ItemBlockWithDescription(int itemID) // { // super(itemID); // } // // @Override // @SideOnly(Side.CLIENT) // public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) // { // if (descriptions.containsKey((Integer) itemStack.itemID)) // { // if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) // { // String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); // for (String line : lines) // { // descriptionList.add(line); // } // } // else // { // descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information")); // } // } // } // } // Path: src/main/java/oceania/blocks/Blocks.java import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import net.minecraftforge.common.Configuration; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.ItemBlockWithDescription; package oceania.blocks; public class Blocks { public static final int DEFAULT_ID_RANGE = 375; public static BlockAtlantiteOre blockAtlantite; public static BlockAtlantiumDepulsor blockDepulsor; public static BlockDepulsorPlaceholder blockPlaceholder; public static BlockLimestone blockLimestone; public static BlockLimestonePillar blockLimestonePillar; public static BlockChestSpawner blockChestSpawner; public static void initBlocks() { Configuration cfg = Oceania.CONFIG; /** Set up instances */ blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); /** Add to registry */ GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite"); GameRegistry.registerBlock(blockDepulsor, ItemBlockWithDescription.class, "blockDepulsor");
GameRegistry.registerBlock(blockLimestone, ItemBlockLimestone.class, "blockLimestone");
TrainerGuy22/Oceania
src/main/java/oceania/items/ItemAtlantiteTrident.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import java.util.List; import org.lwjgl.input.Keyboard; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import oceania.Oceania; import oceania.util.OUtil; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword;
package oceania.items; public class ItemAtlantiteTrident extends ItemSword { public ItemAtlantiteTrident(int par1) { super(par1, Items.TOOL_MATERIAL_ATLANTIUM);
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/items/ItemAtlantiteTrident.java import java.util.List; import org.lwjgl.input.Keyboard; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import oceania.Oceania; import oceania.util.OUtil; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; package oceania.items; public class ItemAtlantiteTrident extends ItemSword { public ItemAtlantiteTrident(int par1) { super(par1, Items.TOOL_MATERIAL_ATLANTIUM);
setCreativeTab(Oceania.CREATIVE_TAB);
TrainerGuy22/Oceania
src/main/java/oceania/items/ItemAtlantiteTrident.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import java.util.List; import org.lwjgl.input.Keyboard; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import oceania.Oceania; import oceania.util.OUtil; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword;
package oceania.items; public class ItemAtlantiteTrident extends ItemSword { public ItemAtlantiteTrident(int par1) { super(par1, Items.TOOL_MATERIAL_ATLANTIUM); setCreativeTab(Oceania.CREATIVE_TAB); setUnlocalizedName("itemAtlantiteTrident"); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoe) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { descriptionList.add("Nothing can beat the"); descriptionList.add("sharpness of Atlantite."); } else {
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/items/ItemAtlantiteTrident.java import java.util.List; import org.lwjgl.input.Keyboard; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import oceania.Oceania; import oceania.util.OUtil; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; package oceania.items; public class ItemAtlantiteTrident extends ItemSword { public ItemAtlantiteTrident(int par1) { super(par1, Items.TOOL_MATERIAL_ATLANTIUM); setCreativeTab(Oceania.CREATIVE_TAB); setUnlocalizedName("itemAtlantiteTrident"); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoe) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { descriptionList.add("Nothing can beat the"); descriptionList.add("sharpness of Atlantite."); } else {
descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information"));
TrainerGuy22/Oceania
src/main/java/oceania/entity/Entities.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/handler/VillageTradeHandler.java // public class VillageTradeHandler implements IVillageTradeHandler // { // // @Override // public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList list, Random random) // { // for(int count = 0; count < 5; count++) // { // if(random.nextInt(7) == 2) // { // switch(count) // { // case 0: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 5), new ItemStack(Items.itemAtlantiteTrident, 1))); // break; // case 1: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 3), new ItemStack(Blocks.blockLimestone, 16, 0))); // break; // case 2: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 6), new ItemStack(Items.itemMulti, 5, 0))); // break; // case 3: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 2), new ItemStack(Items.itemMulti, 8, 2))); // break; // case 4: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 7), new ItemStack(Items.itemDivingHelmet, 1))); // break; // } // } // } // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import net.minecraft.util.ResourceLocation; import oceania.Oceania; import oceania.handler.VillageTradeHandler; import oceania.util.OUtil; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side;
package oceania.entity; public class Entities { public static int VILLAGER_OCEANIA_ID; public static void initEntities() {
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/handler/VillageTradeHandler.java // public class VillageTradeHandler implements IVillageTradeHandler // { // // @Override // public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList list, Random random) // { // for(int count = 0; count < 5; count++) // { // if(random.nextInt(7) == 2) // { // switch(count) // { // case 0: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 5), new ItemStack(Items.itemAtlantiteTrident, 1))); // break; // case 1: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 3), new ItemStack(Blocks.blockLimestone, 16, 0))); // break; // case 2: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 6), new ItemStack(Items.itemMulti, 5, 0))); // break; // case 3: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 2), new ItemStack(Items.itemMulti, 8, 2))); // break; // case 4: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 7), new ItemStack(Items.itemDivingHelmet, 1))); // break; // } // } // } // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/entity/Entities.java import net.minecraft.util.ResourceLocation; import oceania.Oceania; import oceania.handler.VillageTradeHandler; import oceania.util.OUtil; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; package oceania.entity; public class Entities { public static int VILLAGER_OCEANIA_ID; public static void initEntities() {
EntityRegistry.registerModEntity(EntityOceaniaBoatNormal.class, "OceaniaBoat", 0, Oceania.INSTANCE, 80, 3, true);
TrainerGuy22/Oceania
src/main/java/oceania/entity/Entities.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/handler/VillageTradeHandler.java // public class VillageTradeHandler implements IVillageTradeHandler // { // // @Override // public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList list, Random random) // { // for(int count = 0; count < 5; count++) // { // if(random.nextInt(7) == 2) // { // switch(count) // { // case 0: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 5), new ItemStack(Items.itemAtlantiteTrident, 1))); // break; // case 1: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 3), new ItemStack(Blocks.blockLimestone, 16, 0))); // break; // case 2: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 6), new ItemStack(Items.itemMulti, 5, 0))); // break; // case 3: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 2), new ItemStack(Items.itemMulti, 8, 2))); // break; // case 4: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 7), new ItemStack(Items.itemDivingHelmet, 1))); // break; // } // } // } // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import net.minecraft.util.ResourceLocation; import oceania.Oceania; import oceania.handler.VillageTradeHandler; import oceania.util.OUtil; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side;
package oceania.entity; public class Entities { public static int VILLAGER_OCEANIA_ID; public static void initEntities() { EntityRegistry.registerModEntity(EntityOceaniaBoatNormal.class, "OceaniaBoat", 0, Oceania.INSTANCE, 80, 3, true); EntityRegistry.registerModEntity(EntityOceaniaBoatWithChest.class, "OceaniaBoatWithChest", 1, Oceania.INSTANCE, 80, 3, true); EntityRegistry.registerModEntity(EntitySubmarine.class, "Submarine", 2, Oceania.INSTANCE, 80, 3, true); VILLAGER_OCEANIA_ID = VillagerRegistry.getRegisteredVillagers().size(); VillagerRegistry.instance().registerVillagerId(VILLAGER_OCEANIA_ID); // TODO: Post ModJam - Have a custom skin for the villager.
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/handler/VillageTradeHandler.java // public class VillageTradeHandler implements IVillageTradeHandler // { // // @Override // public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList list, Random random) // { // for(int count = 0; count < 5; count++) // { // if(random.nextInt(7) == 2) // { // switch(count) // { // case 0: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 5), new ItemStack(Items.itemAtlantiteTrident, 1))); // break; // case 1: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 3), new ItemStack(Blocks.blockLimestone, 16, 0))); // break; // case 2: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 6), new ItemStack(Items.itemMulti, 5, 0))); // break; // case 3: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 2), new ItemStack(Items.itemMulti, 8, 2))); // break; // case 4: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 7), new ItemStack(Items.itemDivingHelmet, 1))); // break; // } // } // } // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/entity/Entities.java import net.minecraft.util.ResourceLocation; import oceania.Oceania; import oceania.handler.VillageTradeHandler; import oceania.util.OUtil; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; package oceania.entity; public class Entities { public static int VILLAGER_OCEANIA_ID; public static void initEntities() { EntityRegistry.registerModEntity(EntityOceaniaBoatNormal.class, "OceaniaBoat", 0, Oceania.INSTANCE, 80, 3, true); EntityRegistry.registerModEntity(EntityOceaniaBoatWithChest.class, "OceaniaBoatWithChest", 1, Oceania.INSTANCE, 80, 3, true); EntityRegistry.registerModEntity(EntitySubmarine.class, "Submarine", 2, Oceania.INSTANCE, 80, 3, true); VILLAGER_OCEANIA_ID = VillagerRegistry.getRegisteredVillagers().size(); VillagerRegistry.instance().registerVillagerId(VILLAGER_OCEANIA_ID); // TODO: Post ModJam - Have a custom skin for the villager.
if (OUtil.getSide() == Side.CLIENT)
TrainerGuy22/Oceania
src/main/java/oceania/entity/Entities.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/handler/VillageTradeHandler.java // public class VillageTradeHandler implements IVillageTradeHandler // { // // @Override // public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList list, Random random) // { // for(int count = 0; count < 5; count++) // { // if(random.nextInt(7) == 2) // { // switch(count) // { // case 0: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 5), new ItemStack(Items.itemAtlantiteTrident, 1))); // break; // case 1: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 3), new ItemStack(Blocks.blockLimestone, 16, 0))); // break; // case 2: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 6), new ItemStack(Items.itemMulti, 5, 0))); // break; // case 3: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 2), new ItemStack(Items.itemMulti, 8, 2))); // break; // case 4: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 7), new ItemStack(Items.itemDivingHelmet, 1))); // break; // } // } // } // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import net.minecraft.util.ResourceLocation; import oceania.Oceania; import oceania.handler.VillageTradeHandler; import oceania.util.OUtil; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side;
package oceania.entity; public class Entities { public static int VILLAGER_OCEANIA_ID; public static void initEntities() { EntityRegistry.registerModEntity(EntityOceaniaBoatNormal.class, "OceaniaBoat", 0, Oceania.INSTANCE, 80, 3, true); EntityRegistry.registerModEntity(EntityOceaniaBoatWithChest.class, "OceaniaBoatWithChest", 1, Oceania.INSTANCE, 80, 3, true); EntityRegistry.registerModEntity(EntitySubmarine.class, "Submarine", 2, Oceania.INSTANCE, 80, 3, true); VILLAGER_OCEANIA_ID = VillagerRegistry.getRegisteredVillagers().size(); VillagerRegistry.instance().registerVillagerId(VILLAGER_OCEANIA_ID); // TODO: Post ModJam - Have a custom skin for the villager. if (OUtil.getSide() == Side.CLIENT) VillagerRegistry.instance().registerVillagerSkin(VILLAGER_OCEANIA_ID, new ResourceLocation("textures/entity/villager/smith.png"));
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/handler/VillageTradeHandler.java // public class VillageTradeHandler implements IVillageTradeHandler // { // // @Override // public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList list, Random random) // { // for(int count = 0; count < 5; count++) // { // if(random.nextInt(7) == 2) // { // switch(count) // { // case 0: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 5), new ItemStack(Items.itemAtlantiteTrident, 1))); // break; // case 1: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 3), new ItemStack(Blocks.blockLimestone, 16, 0))); // break; // case 2: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 6), new ItemStack(Items.itemMulti, 5, 0))); // break; // case 3: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 2), new ItemStack(Items.itemMulti, 8, 2))); // break; // case 4: // list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 7), new ItemStack(Items.itemDivingHelmet, 1))); // break; // } // } // } // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/entity/Entities.java import net.minecraft.util.ResourceLocation; import oceania.Oceania; import oceania.handler.VillageTradeHandler; import oceania.util.OUtil; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; package oceania.entity; public class Entities { public static int VILLAGER_OCEANIA_ID; public static void initEntities() { EntityRegistry.registerModEntity(EntityOceaniaBoatNormal.class, "OceaniaBoat", 0, Oceania.INSTANCE, 80, 3, true); EntityRegistry.registerModEntity(EntityOceaniaBoatWithChest.class, "OceaniaBoatWithChest", 1, Oceania.INSTANCE, 80, 3, true); EntityRegistry.registerModEntity(EntitySubmarine.class, "Submarine", 2, Oceania.INSTANCE, 80, 3, true); VILLAGER_OCEANIA_ID = VillagerRegistry.getRegisteredVillagers().size(); VillagerRegistry.instance().registerVillagerId(VILLAGER_OCEANIA_ID); // TODO: Post ModJam - Have a custom skin for the villager. if (OUtil.getSide() == Side.CLIENT) VillagerRegistry.instance().registerVillagerSkin(VILLAGER_OCEANIA_ID, new ResourceLocation("textures/entity/villager/smith.png"));
VillagerRegistry.instance().registerVillageTradeHandler(VILLAGER_OCEANIA_ID, new VillageTradeHandler());
TrainerGuy22/Oceania
src/main/java/oceania/handler/VillageTradeHandler.java
// Path: src/main/java/oceania/blocks/Blocks.java // public class Blocks // { // public static final int DEFAULT_ID_RANGE = 375; // // public static BlockAtlantiteOre blockAtlantite; // public static BlockAtlantiumDepulsor blockDepulsor; // public static BlockDepulsorPlaceholder blockPlaceholder; // public static BlockLimestone blockLimestone; // public static BlockLimestonePillar blockLimestonePillar; // public static BlockChestSpawner blockChestSpawner; // // public static void initBlocks() // { // Configuration cfg = Oceania.CONFIG; // // /** Set up instances */ // blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); // blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); // blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); // blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); // // /** Add to registry */ // GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite"); // GameRegistry.registerBlock(blockDepulsor, ItemBlockWithDescription.class, "blockDepulsor"); // GameRegistry.registerBlock(blockLimestone, ItemBlockLimestone.class, "blockLimestone"); // GameRegistry.registerBlock(blockLimestonePillar, ItemBlockWithDescription.class, "blockLimestonePillar"); // GameRegistry.registerBlock(blockPlaceholder, "blockDepulsorPlaceholder"); // GameRegistry.registerBlock(blockChestSpawner, ItemBlockWithDescription.class, "blockChestSpawner"); // // /** Add language */ // LanguageRegistry.addName(blockAtlantite, "Atlantite Ore"); // LanguageRegistry.addName(blockDepulsor, "Atlantium Depulsor"); // LanguageRegistry.addName(blockLimestonePillar, "Limestone Pillar"); // LanguageRegistry.addName(blockChestSpawner, "Chest Spawner"); // } // }
import java.util.Random; import oceania.blocks.Blocks; import oceania.items.Items; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
package oceania.handler; public class VillageTradeHandler implements IVillageTradeHandler { @Override public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList list, Random random) { for(int count = 0; count < 5; count++) { if(random.nextInt(7) == 2) { switch(count) { case 0: list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 5), new ItemStack(Items.itemAtlantiteTrident, 1))); break; case 1:
// Path: src/main/java/oceania/blocks/Blocks.java // public class Blocks // { // public static final int DEFAULT_ID_RANGE = 375; // // public static BlockAtlantiteOre blockAtlantite; // public static BlockAtlantiumDepulsor blockDepulsor; // public static BlockDepulsorPlaceholder blockPlaceholder; // public static BlockLimestone blockLimestone; // public static BlockLimestonePillar blockLimestonePillar; // public static BlockChestSpawner blockChestSpawner; // // public static void initBlocks() // { // Configuration cfg = Oceania.CONFIG; // // /** Set up instances */ // blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); // blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); // blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); // blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); // // /** Add to registry */ // GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite"); // GameRegistry.registerBlock(blockDepulsor, ItemBlockWithDescription.class, "blockDepulsor"); // GameRegistry.registerBlock(blockLimestone, ItemBlockLimestone.class, "blockLimestone"); // GameRegistry.registerBlock(blockLimestonePillar, ItemBlockWithDescription.class, "blockLimestonePillar"); // GameRegistry.registerBlock(blockPlaceholder, "blockDepulsorPlaceholder"); // GameRegistry.registerBlock(blockChestSpawner, ItemBlockWithDescription.class, "blockChestSpawner"); // // /** Add language */ // LanguageRegistry.addName(blockAtlantite, "Atlantite Ore"); // LanguageRegistry.addName(blockDepulsor, "Atlantium Depulsor"); // LanguageRegistry.addName(blockLimestonePillar, "Limestone Pillar"); // LanguageRegistry.addName(blockChestSpawner, "Chest Spawner"); // } // } // Path: src/main/java/oceania/handler/VillageTradeHandler.java import java.util.Random; import oceania.blocks.Blocks; import oceania.items.Items; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler; package oceania.handler; public class VillageTradeHandler implements IVillageTradeHandler { @Override public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList list, Random random) { for(int count = 0; count < 5; count++) { if(random.nextInt(7) == 2) { switch(count) { case 0: list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 5), new ItemStack(Items.itemAtlantiteTrident, 1))); break; case 1:
list.addToListWithCheck(new MerchantRecipe(new ItemStack(Item.emerald, 3), new ItemStack(Blocks.blockLimestone, 16, 0)));
TrainerGuy22/Oceania
src/main/java/oceania/entity/EntityOceaniaBoatWithChest.java
// Path: src/main/java/oceania/util/BoatType.java // public enum BoatType { // WOOD("minecraft", "boat", "Wooden Boat", new ResourceLocation("textures/entity/boat.png"), new ItemStack(Items.stick), 20), // IRON("oceania", "ironBoat", "Iron Boat", new ResourceLocation("oceania", "textures/models/ironBoat.png"), new ItemStack(Items.iron_ingot), 75), // ATLANTIUM("oceania", "atlantiumBoat", "Atlantium Boat", new ResourceLocation("oceania", "textures/models/atlantiumBoat.png"), new ItemStack(Items.itemMulti, 1, ItemMultiType.ATLANTIUM.ordinal()), 450), // SUBMARINE("oceania", "submarine", "Submarine", new ResourceLocation("oceania", "texture/models/submarine.png"), new ItemStack(Items.itemMulti, 1, ItemMultiType.ATLANTIUM.ordinal()), 950); // // public String namespace, unloc, loc; // public int strength; // public ResourceLocation worldTexture; // public ItemStack resourceItem; // // private BoatType(String namespace, String unlocName, String locName, ResourceLocation worldTexture, ItemStack item, int strength) { // this.namespace = namespace; // this.unloc = unlocName; // this.loc = locName; // this.worldTexture = worldTexture; // this.resourceItem = item; // this.strength = strength; // } // // }
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import oceania.items.Items; import oceania.util.BoatType;
package oceania.entity; public class EntityOceaniaBoatWithChest extends EntityOceaniaBoatNormal implements IInventory { private ItemStack[] chestItems = new ItemStack[36]; public EntityOceaniaBoatWithChest(World world) { super(world); this.waterOffset = 1.5f; } public EntityOceaniaBoatWithChest(World world, double x, double y, double z) { this(world); setPosition(x, y, z); }
// Path: src/main/java/oceania/util/BoatType.java // public enum BoatType { // WOOD("minecraft", "boat", "Wooden Boat", new ResourceLocation("textures/entity/boat.png"), new ItemStack(Items.stick), 20), // IRON("oceania", "ironBoat", "Iron Boat", new ResourceLocation("oceania", "textures/models/ironBoat.png"), new ItemStack(Items.iron_ingot), 75), // ATLANTIUM("oceania", "atlantiumBoat", "Atlantium Boat", new ResourceLocation("oceania", "textures/models/atlantiumBoat.png"), new ItemStack(Items.itemMulti, 1, ItemMultiType.ATLANTIUM.ordinal()), 450), // SUBMARINE("oceania", "submarine", "Submarine", new ResourceLocation("oceania", "texture/models/submarine.png"), new ItemStack(Items.itemMulti, 1, ItemMultiType.ATLANTIUM.ordinal()), 950); // // public String namespace, unloc, loc; // public int strength; // public ResourceLocation worldTexture; // public ItemStack resourceItem; // // private BoatType(String namespace, String unlocName, String locName, ResourceLocation worldTexture, ItemStack item, int strength) { // this.namespace = namespace; // this.unloc = unlocName; // this.loc = locName; // this.worldTexture = worldTexture; // this.resourceItem = item; // this.strength = strength; // } // // } // Path: src/main/java/oceania/entity/EntityOceaniaBoatWithChest.java import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import oceania.items.Items; import oceania.util.BoatType; package oceania.entity; public class EntityOceaniaBoatWithChest extends EntityOceaniaBoatNormal implements IInventory { private ItemStack[] chestItems = new ItemStack[36]; public EntityOceaniaBoatWithChest(World world) { super(world); this.waterOffset = 1.5f; } public EntityOceaniaBoatWithChest(World world, double x, double y, double z) { this(world); setPosition(x, y, z); }
public EntityOceaniaBoatWithChest(World world, BoatType type, double x, double y, double z)
TrainerGuy22/Oceania
src/main/java/oceania/blocks/BlockLimestone.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // }
import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.Items; import oceania.items.ItemMulti.ItemMultiType; import oceania.util.IconRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World;
package oceania.blocks; public class BlockLimestone extends Block { public enum LimestoneTypes { LIMESTONE("limestone", "Limestone"), LIMESTONE_BRICK("limestoneBrick", "Limestone Brick"); private String _unloc, _loc; private LimestoneTypes(String unlocName, String locName) { this._unloc = unlocName; this._loc = locName; } public String getUnlocalizedName() { return this._unloc; } public String getLocalizedName() { return this._loc; } } public BlockLimestone(int id) { super(id, Material.rock);
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // } // Path: src/main/java/oceania/blocks/BlockLimestone.java import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.Items; import oceania.items.ItemMulti.ItemMultiType; import oceania.util.IconRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World; package oceania.blocks; public class BlockLimestone extends Block { public enum LimestoneTypes { LIMESTONE("limestone", "Limestone"), LIMESTONE_BRICK("limestoneBrick", "Limestone Brick"); private String _unloc, _loc; private LimestoneTypes(String unlocName, String locName) { this._unloc = unlocName; this._loc = locName; } public String getUnlocalizedName() { return this._unloc; } public String getLocalizedName() { return this._loc; } } public BlockLimestone(int id) { super(id, Material.rock);
setCreativeTab(Oceania.CREATIVE_TAB);
TrainerGuy22/Oceania
src/main/java/oceania/blocks/BlockLimestone.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // }
import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.Items; import oceania.items.ItemMulti.ItemMultiType; import oceania.util.IconRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World;
package oceania.blocks; public class BlockLimestone extends Block { public enum LimestoneTypes { LIMESTONE("limestone", "Limestone"), LIMESTONE_BRICK("limestoneBrick", "Limestone Brick"); private String _unloc, _loc; private LimestoneTypes(String unlocName, String locName) { this._unloc = unlocName; this._loc = locName; } public String getUnlocalizedName() { return this._unloc; } public String getLocalizedName() { return this._loc; } } public BlockLimestone(int id) { super(id, Material.rock); setCreativeTab(Oceania.CREATIVE_TAB); this.setHardness(1.5F); this.setResistance(10.0F); this.setStepSound(soundStoneFootstep);
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // } // Path: src/main/java/oceania/blocks/BlockLimestone.java import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.Items; import oceania.items.ItemMulti.ItemMultiType; import oceania.util.IconRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World; package oceania.blocks; public class BlockLimestone extends Block { public enum LimestoneTypes { LIMESTONE("limestone", "Limestone"), LIMESTONE_BRICK("limestoneBrick", "Limestone Brick"); private String _unloc, _loc; private LimestoneTypes(String unlocName, String locName) { this._unloc = unlocName; this._loc = locName; } public String getUnlocalizedName() { return this._unloc; } public String getLocalizedName() { return this._loc; } } public BlockLimestone(int id) { super(id, Material.rock); setCreativeTab(Oceania.CREATIVE_TAB); this.setHardness(1.5F); this.setResistance(10.0F); this.setStepSound(soundStoneFootstep);
ItemBlockLimestone.registerDescription(this, "A mineral deposit, good for\ndecoration.");
TrainerGuy22/Oceania
src/main/java/oceania/blocks/BlockLimestone.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // }
import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.Items; import oceania.items.ItemMulti.ItemMultiType; import oceania.util.IconRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World;
} public String getLocalizedName() { return this._loc; } } public BlockLimestone(int id) { super(id, Material.rock); setCreativeTab(Oceania.CREATIVE_TAB); this.setHardness(1.5F); this.setResistance(10.0F); this.setStepSound(soundStoneFootstep); ItemBlockLimestone.registerDescription(this, "A mineral deposit, good for\ndecoration."); } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister registry) { for(int index = 0; index < LimestoneTypes.values().length; index++) {
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/items/ItemBlockLimestone.java // public class ItemBlockLimestone extends ItemBlockWithDescription // { // // public ItemBlockLimestone(int itemID) // { // super(itemID); // this.hasSubtypes = true; // for(BlockLimestone.LimestoneTypes multiType : BlockLimestone.LimestoneTypes.values()) // { // LanguageRegistry.instance().addStringLocalization("tile." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); // } // } // // @Override // @SideOnly(Side.CLIENT) // public String getUnlocalizedName(ItemStack stack) // { // return "tile." + BlockLimestone.LimestoneTypes.values()[stack.getItemDamage()].getUnlocalizedName(); // } // // @Override // @SideOnly(Side.CLIENT) // public void getSubItems(int ID, CreativeTabs tabs, List list) // { // for(int index = 0; index < BlockLimestone.LimestoneTypes.values().length; index++) // { // list.add(new ItemStack(ID, 1, index)); // } // } // // } // // Path: src/main/java/oceania/items/ItemMulti.java // public enum ItemMultiType // { // ATLANTITE("rawAtlantium", "Raw Atlantite"), // ATLANTIUM("atlantium", "Atlantium"), // SCREW("screw", "Screw"); // // private String _unloc, _loc; // private ItemMultiType(String unlocName, String locName) // { // this._unloc = unlocName; // this._loc = locName; // } // // public String getUnlocalizedName() // { // return this._unloc; // } // // public String getLocalizedName() // { // return this._loc; // } // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // } // Path: src/main/java/oceania/blocks/BlockLimestone.java import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import oceania.Oceania; import oceania.items.ItemBlockLimestone; import oceania.items.Items; import oceania.items.ItemMulti.ItemMultiType; import oceania.util.IconRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World; } public String getLocalizedName() { return this._loc; } } public BlockLimestone(int id) { super(id, Material.rock); setCreativeTab(Oceania.CREATIVE_TAB); this.setHardness(1.5F); this.setResistance(10.0F); this.setStepSound(soundStoneFootstep); ItemBlockLimestone.registerDescription(this, "A mineral deposit, good for\ndecoration."); } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister registry) { for(int index = 0; index < LimestoneTypes.values().length; index++) {
IconRegistry.setIcon(LimestoneTypes.values()[index].getUnlocalizedName(), registry.registerIcon(Oceania.MOD_ID + ":" + LimestoneTypes.values()[index].getUnlocalizedName()));
TrainerGuy22/Oceania
src/main/java/oceania/blocks/BlockDepulsorPlaceholder.java
// Path: src/main/java/oceania/material/MaterialPlaceholder.java // public class MaterialPlaceholder extends Material // { // // public MaterialPlaceholder() // { // super(MapColor.airColor); // } // // @Override // public boolean blocksMovement() // { // return true; // } // // @Override // public boolean isReplaceable() // { // return true; // } // // @Override // public boolean isSolid() // { // return false; // } // // @Override // public boolean isOpaque() // { // return false; // } // // }
import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import oceania.material.MaterialPlaceholder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
package oceania.blocks; public class BlockDepulsorPlaceholder extends Block { public BlockDepulsorPlaceholder(int blockID) {
// Path: src/main/java/oceania/material/MaterialPlaceholder.java // public class MaterialPlaceholder extends Material // { // // public MaterialPlaceholder() // { // super(MapColor.airColor); // } // // @Override // public boolean blocksMovement() // { // return true; // } // // @Override // public boolean isReplaceable() // { // return true; // } // // @Override // public boolean isSolid() // { // return false; // } // // @Override // public boolean isOpaque() // { // return false; // } // // } // Path: src/main/java/oceania/blocks/BlockDepulsorPlaceholder.java import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import oceania.material.MaterialPlaceholder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; package oceania.blocks; public class BlockDepulsorPlaceholder extends Block { public BlockDepulsorPlaceholder(int blockID) {
super(blockID, new MaterialPlaceholder());
TrainerGuy22/Oceania
src/main/java/oceania/gen/WorldGenAtlantite.java
// Path: src/main/java/oceania/blocks/Blocks.java // public class Blocks // { // public static final int DEFAULT_ID_RANGE = 375; // // public static BlockAtlantiteOre blockAtlantite; // public static BlockAtlantiumDepulsor blockDepulsor; // public static BlockDepulsorPlaceholder blockPlaceholder; // public static BlockLimestone blockLimestone; // public static BlockLimestonePillar blockLimestonePillar; // public static BlockChestSpawner blockChestSpawner; // // public static void initBlocks() // { // Configuration cfg = Oceania.CONFIG; // // /** Set up instances */ // blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); // blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); // blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); // blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); // // /** Add to registry */ // GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite"); // GameRegistry.registerBlock(blockDepulsor, ItemBlockWithDescription.class, "blockDepulsor"); // GameRegistry.registerBlock(blockLimestone, ItemBlockLimestone.class, "blockLimestone"); // GameRegistry.registerBlock(blockLimestonePillar, ItemBlockWithDescription.class, "blockLimestonePillar"); // GameRegistry.registerBlock(blockPlaceholder, "blockDepulsorPlaceholder"); // GameRegistry.registerBlock(blockChestSpawner, ItemBlockWithDescription.class, "blockChestSpawner"); // // /** Add language */ // LanguageRegistry.addName(blockAtlantite, "Atlantite Ore"); // LanguageRegistry.addName(blockDepulsor, "Atlantium Depulsor"); // LanguageRegistry.addName(blockLimestonePillar, "Limestone Pillar"); // LanguageRegistry.addName(blockChestSpawner, "Chest Spawner"); // } // }
import java.util.Random; import oceania.blocks.Blocks; import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import cpw.mods.fml.common.IWorldGenerator;
package oceania.gen; public class WorldGenAtlantite implements IWorldGenerator { private int _veinSize; private int _veinCount; public WorldGenAtlantite(int veinSize, int veinsPerChunk) { this._veinSize = veinSize; this._veinCount = veinsPerChunk; } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if (world.provider.dimensionId == 0 /** Surface world */) { int chunkBlockX = chunkX * 16; int chunkBlockZ = chunkZ * 16; if (world.getBiomeGenForCoords(chunkBlockX, chunkBlockZ) == BiomeGenBase.ocean) // Generate in the ocean { generateOre(world, random, chunkBlockX, chunkBlockZ); } } } private void generateOre(World world, Random random, int chunkBlockX, int chunkBlockZ) {
// Path: src/main/java/oceania/blocks/Blocks.java // public class Blocks // { // public static final int DEFAULT_ID_RANGE = 375; // // public static BlockAtlantiteOre blockAtlantite; // public static BlockAtlantiumDepulsor blockDepulsor; // public static BlockDepulsorPlaceholder blockPlaceholder; // public static BlockLimestone blockLimestone; // public static BlockLimestonePillar blockLimestonePillar; // public static BlockChestSpawner blockChestSpawner; // // public static void initBlocks() // { // Configuration cfg = Oceania.CONFIG; // // /** Set up instances */ // blockAtlantite = new BlockAtlantiteOre(cfg.getBlock("oreAtlantite", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockDepulsor = new BlockAtlantiumDepulsor(cfg.getBlock("machineDepulsor", DEFAULT_ID_RANGE).getInt(DEFAULT_ID_RANGE)); // blockPlaceholder = new BlockDepulsorPlaceholder(cfg.getBlock("blockDepulsorPlaceholder", DEFAULT_ID_RANGE, "The block that is used in the depulsor's \"air bubble\"").getInt()); // blockLimestone = new BlockLimestone(cfg.getBlock("blockLimestone", DEFAULT_ID_RANGE + 1).getInt(DEFAULT_ID_RANGE + 1)); // blockLimestonePillar = new BlockLimestonePillar(cfg.getBlock("blockLimestonePillar", DEFAULT_ID_RANGE + 2).getInt(DEFAULT_ID_RANGE + 2)); // blockChestSpawner = new BlockChestSpawner(cfg.getBlock("blockChestSpawner", DEFAULT_ID_RANGE + 3).getInt(DEFAULT_ID_RANGE + 3)); // // /** Add to registry */ // GameRegistry.registerBlock(blockAtlantite, ItemBlockWithDescription.class, "blockAtlantite"); // GameRegistry.registerBlock(blockDepulsor, ItemBlockWithDescription.class, "blockDepulsor"); // GameRegistry.registerBlock(blockLimestone, ItemBlockLimestone.class, "blockLimestone"); // GameRegistry.registerBlock(blockLimestonePillar, ItemBlockWithDescription.class, "blockLimestonePillar"); // GameRegistry.registerBlock(blockPlaceholder, "blockDepulsorPlaceholder"); // GameRegistry.registerBlock(blockChestSpawner, ItemBlockWithDescription.class, "blockChestSpawner"); // // /** Add language */ // LanguageRegistry.addName(blockAtlantite, "Atlantite Ore"); // LanguageRegistry.addName(blockDepulsor, "Atlantium Depulsor"); // LanguageRegistry.addName(blockLimestonePillar, "Limestone Pillar"); // LanguageRegistry.addName(blockChestSpawner, "Chest Spawner"); // } // } // Path: src/main/java/oceania/gen/WorldGenAtlantite.java import java.util.Random; import oceania.blocks.Blocks; import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import cpw.mods.fml.common.IWorldGenerator; package oceania.gen; public class WorldGenAtlantite implements IWorldGenerator { private int _veinSize; private int _veinCount; public WorldGenAtlantite(int veinSize, int veinsPerChunk) { this._veinSize = veinSize; this._veinCount = veinsPerChunk; } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if (world.provider.dimensionId == 0 /** Surface world */) { int chunkBlockX = chunkX * 16; int chunkBlockZ = chunkZ * 16; if (world.getBiomeGenForCoords(chunkBlockX, chunkBlockZ) == BiomeGenBase.ocean) // Generate in the ocean { generateOre(world, random, chunkBlockX, chunkBlockZ); } } } private void generateOre(World world, Random random, int chunkBlockX, int chunkBlockZ) {
WorldGenMinable gen = new WorldGenMinable(Blocks.blockAtlantite.blockID, this._veinSize, Block.sand.blockID);
TrainerGuy22/Oceania
src/main/java/oceania/items/ItemBlockWithDescription.java
// Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import java.util.HashMap; import java.util.List; import oceania.util.OUtil; import org.lwjgl.input.Keyboard; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack;
package oceania.items; public class ItemBlockWithDescription extends ItemBlock { private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); public static void registerDescription(Block block, String description) { descriptions.put(block.blockID, description); } public ItemBlockWithDescription(int itemID) { super(itemID); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) { if (descriptions.containsKey((Integer) itemStack.itemID)) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); for (String line : lines) { descriptionList.add(line); } } else {
// Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/items/ItemBlockWithDescription.java import java.util.HashMap; import java.util.List; import oceania.util.OUtil; import org.lwjgl.input.Keyboard; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; package oceania.items; public class ItemBlockWithDescription extends ItemBlock { private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); public static void registerDescription(Block block, String description) { descriptions.put(block.blockID, description); } public ItemBlockWithDescription(int itemID) { super(itemID); } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) { if (descriptions.containsKey((Integer) itemStack.itemID)) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { String[] lines = descriptions.get((Integer) itemStack.itemID).split("\n"); for (String line : lines) { descriptionList.add(line); } } else {
descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information"));
TrainerGuy22/Oceania
src/main/java/oceania/items/ItemMulti.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import java.util.HashMap; import java.util.List; import org.lwjgl.input.Keyboard; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import oceania.Oceania; import oceania.util.IconRegistry; import oceania.util.OUtil; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
private String _unloc, _loc; private ItemMultiType(String unlocName, String locName) { this._unloc = unlocName; this._loc = locName; } public String getUnlocalizedName() { return this._unloc; } public String getLocalizedName() { return this._loc; } } private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); static { descriptions.put(0, "Some sort of naturally occuring\nalloy..."); descriptions.put(1, "Refined Atlantite. Much harder,\nbut much duller!"); descriptions.put(2, "Holds things together. Hopefully."); } public ItemMulti(int par1) { super(par1);
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/items/ItemMulti.java import java.util.HashMap; import java.util.List; import org.lwjgl.input.Keyboard; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import oceania.Oceania; import oceania.util.IconRegistry; import oceania.util.OUtil; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; private String _unloc, _loc; private ItemMultiType(String unlocName, String locName) { this._unloc = unlocName; this._loc = locName; } public String getUnlocalizedName() { return this._unloc; } public String getLocalizedName() { return this._loc; } } private static HashMap<Integer, String> descriptions = new HashMap<Integer, String>(); static { descriptions.put(0, "Some sort of naturally occuring\nalloy..."); descriptions.put(1, "Refined Atlantite. Much harder,\nbut much duller!"); descriptions.put(2, "Holds things together. Hopefully."); } public ItemMulti(int par1) { super(par1);
setCreativeTab(Oceania.CREATIVE_TAB);
TrainerGuy22/Oceania
src/main/java/oceania/items/ItemMulti.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import java.util.HashMap; import java.util.List; import org.lwjgl.input.Keyboard; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import oceania.Oceania; import oceania.util.IconRegistry; import oceania.util.OUtil; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
{ descriptions.put(0, "Some sort of naturally occuring\nalloy..."); descriptions.put(1, "Refined Atlantite. Much harder,\nbut much duller!"); descriptions.put(2, "Holds things together. Hopefully."); } public ItemMulti(int par1) { super(par1); setCreativeTab(Oceania.CREATIVE_TAB); this.hasSubtypes = true; for(ItemMultiType multiType : ItemMultiType.values()) { LanguageRegistry.instance().addStringLocalization("item.sub." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); } } @Override @SideOnly(Side.CLIENT) public String getUnlocalizedName(ItemStack stack) { return "item.sub." + ItemMultiType.values()[stack.getItemDamage()].getUnlocalizedName(); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister registry) { for(int index = 0; index < ItemMultiType.values().length; index++) {
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/items/ItemMulti.java import java.util.HashMap; import java.util.List; import org.lwjgl.input.Keyboard; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import oceania.Oceania; import oceania.util.IconRegistry; import oceania.util.OUtil; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; { descriptions.put(0, "Some sort of naturally occuring\nalloy..."); descriptions.put(1, "Refined Atlantite. Much harder,\nbut much duller!"); descriptions.put(2, "Holds things together. Hopefully."); } public ItemMulti(int par1) { super(par1); setCreativeTab(Oceania.CREATIVE_TAB); this.hasSubtypes = true; for(ItemMultiType multiType : ItemMultiType.values()) { LanguageRegistry.instance().addStringLocalization("item.sub." + multiType.getUnlocalizedName() + ".name", multiType.getLocalizedName()); } } @Override @SideOnly(Side.CLIENT) public String getUnlocalizedName(ItemStack stack) { return "item.sub." + ItemMultiType.values()[stack.getItemDamage()].getUnlocalizedName(); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister registry) { for(int index = 0; index < ItemMultiType.values().length; index++) {
IconRegistry.setIcon(ItemMultiType.values()[index].getUnlocalizedName(), registry.registerIcon(Oceania.MOD_ID + ":" + ItemMultiType.values()[index].getUnlocalizedName()));
TrainerGuy22/Oceania
src/main/java/oceania/items/ItemMulti.java
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // }
import java.util.HashMap; import java.util.List; import org.lwjgl.input.Keyboard; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import oceania.Oceania; import oceania.util.IconRegistry; import oceania.util.OUtil; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly;
{ return IconRegistry.getIcon(ItemMultiType.values()[meta].getUnlocalizedName()); } @Override @SideOnly(Side.CLIENT) public void getSubItems(int ID, CreativeTabs tabs, List list) { for(int index = 0; index < ItemMultiType.values().length; index++) { list.add(new ItemStack(ID, 1, index)); } } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) { if (descriptions.containsKey((Integer) itemStack.getItemDamage())) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { String[] lines = descriptions.get((Integer) itemStack.getItemDamage()).split("\n"); for (String line : lines) { descriptionList.add(line); } } else {
// Path: src/main/java/oceania/Oceania.java // @Mod(name = "Oceania", modid = Oceania.MOD_ID, version = Oceania.VERSION) // @SandstoneMod(basePackage = "oceania") // public class Oceania { // // public static final String MOD_NAME = "Oceania"; // public static final String MOD_ID = "oceania"; // public static final String VERSION = "1.1.0"; // // @Instance(Oceania.MOD_ID) // public static Oceania INSTANCE; // // @SidedProxy(clientSide = "oceania.client.ClientProxy", serverSide = "oceania.common.CommonProxy") // public static CommonProxy PROXY; // // public static Config CONFIG; // public static CreativeTabOceania TAB; // // @EventHandler // public void preInit(FMLPreInitializationEvent event) { // CONFIG = Config.toml(new File(event.getModConfigurationDirectory(), Oceania.MOD_ID + ".toml")); // Oceania.PROXY.init(); // } // // } // // Path: src/main/java/oceania/util/IconRegistry.java // public class IconRegistry { // // public static Map<String, IIcon> ICONS = new HashMap<String, IIcon>(); // // public static boolean hasIcon(String value) { // return ICONS.containsKey(value); // } // // public static void setIcon(String value, IIcon icon) { // ICONS.put(value, icon); // } // // public static IIcon getIcon(String value) { // return ICONS.get(value); // } // // } // // Path: src/main/java/oceania/util/OUtil.java // public class OUtil { // public static final float PI_OVER_180 = (float) Math.PI / 180.0f; // public static final String COLOR_CODE = "\u00A7"; // // public static String colorString(String input) { // return input.replaceAll("&&", COLOR_CODE); // } // // @SideOnly(Side.CLIENT) // public static void bindTexture(ResourceLocation textureLocation) // { // Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation); // } // // public static Side getSide() // { // return FMLCommonHandler.instance().getEffectiveSide(); // } // } // Path: src/main/java/oceania/items/ItemMulti.java import java.util.HashMap; import java.util.List; import org.lwjgl.input.Keyboard; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import oceania.Oceania; import oceania.util.IconRegistry; import oceania.util.OUtil; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; { return IconRegistry.getIcon(ItemMultiType.values()[meta].getUnlocalizedName()); } @Override @SideOnly(Side.CLIENT) public void getSubItems(int ID, CreativeTabs tabs, List list) { for(int index = 0; index < ItemMultiType.values().length; index++) { list.add(new ItemStack(ID, 1, index)); } } @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List descriptionList, boolean noClueWhatThisEvenDoes) { if (descriptions.containsKey((Integer) itemStack.getItemDamage())) { if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { String[] lines = descriptions.get((Integer) itemStack.getItemDamage()).split("\n"); for (String line : lines) { descriptionList.add(line); } } else {
descriptionList.add(OUtil.colorString("Hold &&9SHIFT &&7for more information"));
matejdro/PebbleAndroidCommons
src/main/java/com/matejdro/pebblecommons/pebble/AckNackReceiver.java
// Path: src/main/java/com/matejdro/pebblecommons/PebbleCompanionApplication.java // public abstract class PebbleCompanionApplication extends Application // { // private static PebbleCompanionApplication instance; // // @Override // public void onCreate() // { // instance = this; // // super.onCreate(); // } // // public static PebbleCompanionApplication getInstance() // { // return instance; // } // // public abstract UUID getPebbleAppUUID(); // public abstract Class<? extends PebbleTalkerService> getTalkerServiceClass(); // // public @Nullable Map<String, String> getTextReplacementTable() // { // return null; // } // // public static PebbleCompanionApplication fromContext(Context context) // { // return (PebbleCompanionApplication) context.getApplicationContext(); // } // } // // Path: src/main/java/com/getpebble/android/kit/Constants.java // public static final String TRANSACTION_ID = "transaction_id";
import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ComponentInfo; import android.os.Handler; import com.matejdro.pebblecommons.PebbleCompanionApplication; import static com.getpebble.android.kit.Constants.TRANSACTION_ID;
package com.matejdro.pebblecommons.pebble; public class AckNackReceiver extends BroadcastReceiver { private Context context; public AckNackReceiver(Context context) { this.context = context; } public void register() { context.registerReceiver(this, new IntentFilter("com.getpebble.action.app.RECEIVE_ACK")); context.registerReceiver(this, new IntentFilter("com.getpebble.action.app.RECEIVE_NACK")); } public void unregister() { context.unregisterReceiver(this); } @Override public void onReceive(Context context, Intent intent) {
// Path: src/main/java/com/matejdro/pebblecommons/PebbleCompanionApplication.java // public abstract class PebbleCompanionApplication extends Application // { // private static PebbleCompanionApplication instance; // // @Override // public void onCreate() // { // instance = this; // // super.onCreate(); // } // // public static PebbleCompanionApplication getInstance() // { // return instance; // } // // public abstract UUID getPebbleAppUUID(); // public abstract Class<? extends PebbleTalkerService> getTalkerServiceClass(); // // public @Nullable Map<String, String> getTextReplacementTable() // { // return null; // } // // public static PebbleCompanionApplication fromContext(Context context) // { // return (PebbleCompanionApplication) context.getApplicationContext(); // } // } // // Path: src/main/java/com/getpebble/android/kit/Constants.java // public static final String TRANSACTION_ID = "transaction_id"; // Path: src/main/java/com/matejdro/pebblecommons/pebble/AckNackReceiver.java import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ComponentInfo; import android.os.Handler; import com.matejdro.pebblecommons.PebbleCompanionApplication; import static com.getpebble.android.kit.Constants.TRANSACTION_ID; package com.matejdro.pebblecommons.pebble; public class AckNackReceiver extends BroadcastReceiver { private Context context; public AckNackReceiver(Context context) { this.context = context; } public void register() { context.registerReceiver(this, new IntentFilter("com.getpebble.action.app.RECEIVE_ACK")); context.registerReceiver(this, new IntentFilter("com.getpebble.action.app.RECEIVE_NACK")); } public void unregister() { context.unregisterReceiver(this); } @Override public void onReceive(Context context, Intent intent) {
final int transactionId = intent.getIntExtra(TRANSACTION_ID, -1);
matejdro/PebbleAndroidCommons
src/main/java/com/matejdro/pebblecommons/pebble/AckNackReceiver.java
// Path: src/main/java/com/matejdro/pebblecommons/PebbleCompanionApplication.java // public abstract class PebbleCompanionApplication extends Application // { // private static PebbleCompanionApplication instance; // // @Override // public void onCreate() // { // instance = this; // // super.onCreate(); // } // // public static PebbleCompanionApplication getInstance() // { // return instance; // } // // public abstract UUID getPebbleAppUUID(); // public abstract Class<? extends PebbleTalkerService> getTalkerServiceClass(); // // public @Nullable Map<String, String> getTextReplacementTable() // { // return null; // } // // public static PebbleCompanionApplication fromContext(Context context) // { // return (PebbleCompanionApplication) context.getApplicationContext(); // } // } // // Path: src/main/java/com/getpebble/android/kit/Constants.java // public static final String TRANSACTION_ID = "transaction_id";
import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ComponentInfo; import android.os.Handler; import com.matejdro.pebblecommons.PebbleCompanionApplication; import static com.getpebble.android.kit.Constants.TRANSACTION_ID;
package com.matejdro.pebblecommons.pebble; public class AckNackReceiver extends BroadcastReceiver { private Context context; public AckNackReceiver(Context context) { this.context = context; } public void register() { context.registerReceiver(this, new IntentFilter("com.getpebble.action.app.RECEIVE_ACK")); context.registerReceiver(this, new IntentFilter("com.getpebble.action.app.RECEIVE_NACK")); } public void unregister() { context.unregisterReceiver(this); } @Override public void onReceive(Context context, Intent intent) { final int transactionId = intent.getIntExtra(TRANSACTION_ID, -1); if ("com.getpebble.action.app.RECEIVE_ACK".equals(intent.getAction())) {
// Path: src/main/java/com/matejdro/pebblecommons/PebbleCompanionApplication.java // public abstract class PebbleCompanionApplication extends Application // { // private static PebbleCompanionApplication instance; // // @Override // public void onCreate() // { // instance = this; // // super.onCreate(); // } // // public static PebbleCompanionApplication getInstance() // { // return instance; // } // // public abstract UUID getPebbleAppUUID(); // public abstract Class<? extends PebbleTalkerService> getTalkerServiceClass(); // // public @Nullable Map<String, String> getTextReplacementTable() // { // return null; // } // // public static PebbleCompanionApplication fromContext(Context context) // { // return (PebbleCompanionApplication) context.getApplicationContext(); // } // } // // Path: src/main/java/com/getpebble/android/kit/Constants.java // public static final String TRANSACTION_ID = "transaction_id"; // Path: src/main/java/com/matejdro/pebblecommons/pebble/AckNackReceiver.java import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ComponentInfo; import android.os.Handler; import com.matejdro.pebblecommons.PebbleCompanionApplication; import static com.getpebble.android.kit.Constants.TRANSACTION_ID; package com.matejdro.pebblecommons.pebble; public class AckNackReceiver extends BroadcastReceiver { private Context context; public AckNackReceiver(Context context) { this.context = context; } public void register() { context.registerReceiver(this, new IntentFilter("com.getpebble.action.app.RECEIVE_ACK")); context.registerReceiver(this, new IntentFilter("com.getpebble.action.app.RECEIVE_NACK")); } public void unregister() { context.unregisterReceiver(this); } @Override public void onReceive(Context context, Intent intent) { final int transactionId = intent.getIntExtra(TRANSACTION_ID, -1); if ("com.getpebble.action.app.RECEIVE_ACK".equals(intent.getAction())) {
Intent outIntent = new Intent(context, PebbleCompanionApplication.getInstance().getTalkerServiceClass());
matejdro/PebbleAndroidCommons
src/main/java/com/matejdro/pebblecommons/util/TextUtil.java
// Path: src/main/java/com/matejdro/pebblecommons/PebbleCompanionApplication.java // public abstract class PebbleCompanionApplication extends Application // { // private static PebbleCompanionApplication instance; // // @Override // public void onCreate() // { // instance = this; // // super.onCreate(); // } // // public static PebbleCompanionApplication getInstance() // { // return instance; // } // // public abstract UUID getPebbleAppUUID(); // public abstract Class<? extends PebbleTalkerService> getTalkerServiceClass(); // // public @Nullable Map<String, String> getTextReplacementTable() // { // return null; // } // // public static PebbleCompanionApplication fromContext(Context context) // { // return (PebbleCompanionApplication) context.getApplicationContext(); // } // }
import com.matejdro.pebblecommons.PebbleCompanionApplication; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException;
package com.matejdro.pebblecommons.util; public class TextUtil { public static String prepareString(String text) { return prepareString(text, 20); } public static String prepareString(String text, int length) { if(text == null) return text; text = trimString(text, length, true); text = fixInternationalCharacters(text); return trimString(text, length, true); } public static String fixInternationalCharacters(String input) { if(input == null) return input;
// Path: src/main/java/com/matejdro/pebblecommons/PebbleCompanionApplication.java // public abstract class PebbleCompanionApplication extends Application // { // private static PebbleCompanionApplication instance; // // @Override // public void onCreate() // { // instance = this; // // super.onCreate(); // } // // public static PebbleCompanionApplication getInstance() // { // return instance; // } // // public abstract UUID getPebbleAppUUID(); // public abstract Class<? extends PebbleTalkerService> getTalkerServiceClass(); // // public @Nullable Map<String, String> getTextReplacementTable() // { // return null; // } // // public static PebbleCompanionApplication fromContext(Context context) // { // return (PebbleCompanionApplication) context.getApplicationContext(); // } // } // Path: src/main/java/com/matejdro/pebblecommons/util/TextUtil.java import com.matejdro.pebblecommons.PebbleCompanionApplication; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; package com.matejdro.pebblecommons.util; public class TextUtil { public static String prepareString(String text) { return prepareString(text, 20); } public static String prepareString(String text, int length) { if(text == null) return text; text = trimString(text, length, true); text = fixInternationalCharacters(text); return trimString(text, length, true); } public static String fixInternationalCharacters(String input) { if(input == null) return input;
Map<String, String> replacementTable = PebbleCompanionApplication.getInstance().getTextReplacementTable();
matejdro/PebbleAndroidCommons
src/test/java/com/matejdro/pebblecommons/vibration/PebbleVibrationPatternTest.java
// Path: src/main/java/com/matejdro/pebblecommons/vibration/PebbleVibrationPattern.java // public class PebbleVibrationPattern // { // public static final int MAX_SEGMENTS = 20; // public static final int MAX_LENGTH_MS = 10000; // // public static final List<Byte> EMPTY_VIBRATION_PATTERN = Arrays.asList(new Byte[]{0, 0}); // // public static List<Byte> parseVibrationPattern(String pattern) // { // String split[] = pattern.split(","); // // List<Byte> bytes = new ArrayList<>(MAX_SEGMENTS * 2); // int max = Math.min(MAX_SEGMENTS, split.length); // int total = 0; // // for (int i = 0; i < max; i++) // { // try // { // int segment = Integer.parseInt(split[i].trim()); // segment = Math.min(segment, MAX_LENGTH_MS - total); // total += segment; // // bytes.add((byte) (segment & 0xFF)); // bytes.add((byte) ((segment >> 8) & 0xFF)); // // if (total >= MAX_LENGTH_MS) // break; // // } catch (NumberFormatException e) // { // } // } // // if (bytes.size() == 0) // { // bytes.add((byte) 0); // bytes.add((byte) 0); // } // // return bytes; // } // // public static List<Byte> getFromAndroidVibrationPattern(long[] pattern) // { // List<Byte> bytes = new ArrayList<>(MAX_SEGMENTS * 2); // int max = Math.min(MAX_SEGMENTS, pattern.length); // int total = 0; // // //Android pattern has one extra pause, so we start at first vibration (pause,vib,pause,vib... instead of vib,pause,vib,pause...) // for (int i = 1; i < max; i++) // { // long segment = pattern[i]; // segment = Math.min(segment, MAX_LENGTH_MS - total); // total += segment; // // bytes.add((byte) (segment & 0xFF)); // bytes.add((byte) ((segment >> 8) & 0xFF)); // // if (total >= MAX_LENGTH_MS) //Maximum total vibration length is 10000 for now // break; // } // // if (bytes.size() == 0) // { // bytes.add((byte) 0); // bytes.add((byte) 0); // } // // return bytes; // } // // public static long[] convertToAndroidPattern(String pebblePattern) // { // List<Long> androidPattern = new ArrayList<>(); // androidPattern.add(0L); // Add beginning pause // // String[] split = pebblePattern.split(","); // // for (String patternSegmentString : split) // { // try // { // int segment = Integer.parseInt(patternSegmentString.trim()); // androidPattern.add((long) segment); // // } catch (NumberFormatException e) // { // } // // } // // long[] primitiveAndroidPattern = new long[androidPattern.size()]; // for (int i = 0; i < androidPattern.size(); i++) // { // primitiveAndroidPattern[i] = androidPattern.get(i); // } // // return primitiveAndroidPattern; // } // // public static boolean validateVibrationPattern(String pattern) // { // if (pattern.trim().isEmpty()) // return false; // // String split[] = pattern.split(",", -1); // // for (String segment : split) // { // try // { // String trimmedSegment = segment.trim(); // Integer number = Integer.parseInt(trimmedSegment); // if (number < 0) // return false; // } // catch (NumberFormatException e) // { // return false; // } // } // // return true; // } // }
import com.matejdro.pebblecommons.vibration.PebbleVibrationPattern; import org.junit.Test; import static org.junit.Assert.*;
package com.matejdro.pebblecommons.vibration; public class PebbleVibrationPatternTest { @Test public void testValidation() {
// Path: src/main/java/com/matejdro/pebblecommons/vibration/PebbleVibrationPattern.java // public class PebbleVibrationPattern // { // public static final int MAX_SEGMENTS = 20; // public static final int MAX_LENGTH_MS = 10000; // // public static final List<Byte> EMPTY_VIBRATION_PATTERN = Arrays.asList(new Byte[]{0, 0}); // // public static List<Byte> parseVibrationPattern(String pattern) // { // String split[] = pattern.split(","); // // List<Byte> bytes = new ArrayList<>(MAX_SEGMENTS * 2); // int max = Math.min(MAX_SEGMENTS, split.length); // int total = 0; // // for (int i = 0; i < max; i++) // { // try // { // int segment = Integer.parseInt(split[i].trim()); // segment = Math.min(segment, MAX_LENGTH_MS - total); // total += segment; // // bytes.add((byte) (segment & 0xFF)); // bytes.add((byte) ((segment >> 8) & 0xFF)); // // if (total >= MAX_LENGTH_MS) // break; // // } catch (NumberFormatException e) // { // } // } // // if (bytes.size() == 0) // { // bytes.add((byte) 0); // bytes.add((byte) 0); // } // // return bytes; // } // // public static List<Byte> getFromAndroidVibrationPattern(long[] pattern) // { // List<Byte> bytes = new ArrayList<>(MAX_SEGMENTS * 2); // int max = Math.min(MAX_SEGMENTS, pattern.length); // int total = 0; // // //Android pattern has one extra pause, so we start at first vibration (pause,vib,pause,vib... instead of vib,pause,vib,pause...) // for (int i = 1; i < max; i++) // { // long segment = pattern[i]; // segment = Math.min(segment, MAX_LENGTH_MS - total); // total += segment; // // bytes.add((byte) (segment & 0xFF)); // bytes.add((byte) ((segment >> 8) & 0xFF)); // // if (total >= MAX_LENGTH_MS) //Maximum total vibration length is 10000 for now // break; // } // // if (bytes.size() == 0) // { // bytes.add((byte) 0); // bytes.add((byte) 0); // } // // return bytes; // } // // public static long[] convertToAndroidPattern(String pebblePattern) // { // List<Long> androidPattern = new ArrayList<>(); // androidPattern.add(0L); // Add beginning pause // // String[] split = pebblePattern.split(","); // // for (String patternSegmentString : split) // { // try // { // int segment = Integer.parseInt(patternSegmentString.trim()); // androidPattern.add((long) segment); // // } catch (NumberFormatException e) // { // } // // } // // long[] primitiveAndroidPattern = new long[androidPattern.size()]; // for (int i = 0; i < androidPattern.size(); i++) // { // primitiveAndroidPattern[i] = androidPattern.get(i); // } // // return primitiveAndroidPattern; // } // // public static boolean validateVibrationPattern(String pattern) // { // if (pattern.trim().isEmpty()) // return false; // // String split[] = pattern.split(",", -1); // // for (String segment : split) // { // try // { // String trimmedSegment = segment.trim(); // Integer number = Integer.parseInt(trimmedSegment); // if (number < 0) // return false; // } // catch (NumberFormatException e) // { // return false; // } // } // // return true; // } // } // Path: src/test/java/com/matejdro/pebblecommons/vibration/PebbleVibrationPatternTest.java import com.matejdro.pebblecommons.vibration.PebbleVibrationPattern; import org.junit.Test; import static org.junit.Assert.*; package com.matejdro.pebblecommons.vibration; public class PebbleVibrationPatternTest { @Test public void testValidation() {
assertFalse(PebbleVibrationPattern.validateVibrationPattern(""));
matejdro/PebbleAndroidCommons
src/main/java/org/java_websocket/SocketChannelIOHelper.java
// Path: src/main/java/org/java_websocket/WebSocket.java // public enum Role { // CLIENT, SERVER // }
import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.ByteChannel; import org.java_websocket.WebSocket.Role;
package org.java_websocket; public class SocketChannelIOHelper { public static boolean read( final ByteBuffer buf, WebSocketImpl ws, ByteChannel channel ) throws IOException { buf.clear(); int read = channel.read( buf ); buf.flip(); if( read == -1 ) { ws.eot(); return false; } return read != 0; } /** * @see WrappedByteChannel#readMore(ByteBuffer) * @return returns whether there is more data left which can be obtained via {@link #readMore(ByteBuffer, WebSocketImpl, WrappedByteChannel)} **/ public static boolean readMore( final ByteBuffer buf, WebSocketImpl ws, WrappedByteChannel channel ) throws IOException { buf.clear(); int read = channel.readMore( buf ); buf.flip(); if( read == -1 ) { ws.eot(); return false; } return channel.isNeedRead(); } /** Returns whether the whole outQueue has been flushed */ public static boolean batch( WebSocketImpl ws, ByteChannel sockchannel ) throws IOException { ByteBuffer buffer = ws.outQueue.peek(); WrappedByteChannel c = null; if( buffer == null ) { if( sockchannel instanceof WrappedByteChannel ) { c = (WrappedByteChannel) sockchannel; if( c.isNeedWrite() ) { c.writeMore(); } } } else { do {// FIXME writing as much as possible is unfair!! /*int written = */sockchannel.write( buffer ); if( buffer.remaining() > 0 ) { return false; } else { ws.outQueue.poll(); // Buffer finished. Remove it. buffer = ws.outQueue.peek(); } } while ( buffer != null ); }
// Path: src/main/java/org/java_websocket/WebSocket.java // public enum Role { // CLIENT, SERVER // } // Path: src/main/java/org/java_websocket/SocketChannelIOHelper.java import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.ByteChannel; import org.java_websocket.WebSocket.Role; package org.java_websocket; public class SocketChannelIOHelper { public static boolean read( final ByteBuffer buf, WebSocketImpl ws, ByteChannel channel ) throws IOException { buf.clear(); int read = channel.read( buf ); buf.flip(); if( read == -1 ) { ws.eot(); return false; } return read != 0; } /** * @see WrappedByteChannel#readMore(ByteBuffer) * @return returns whether there is more data left which can be obtained via {@link #readMore(ByteBuffer, WebSocketImpl, WrappedByteChannel)} **/ public static boolean readMore( final ByteBuffer buf, WebSocketImpl ws, WrappedByteChannel channel ) throws IOException { buf.clear(); int read = channel.readMore( buf ); buf.flip(); if( read == -1 ) { ws.eot(); return false; } return channel.isNeedRead(); } /** Returns whether the whole outQueue has been flushed */ public static boolean batch( WebSocketImpl ws, ByteChannel sockchannel ) throws IOException { ByteBuffer buffer = ws.outQueue.peek(); WrappedByteChannel c = null; if( buffer == null ) { if( sockchannel instanceof WrappedByteChannel ) { c = (WrappedByteChannel) sockchannel; if( c.isNeedWrite() ) { c.writeMore(); } } } else { do {// FIXME writing as much as possible is unfair!! /*int written = */sockchannel.write( buffer ); if( buffer.remaining() > 0 ) { return false; } else { ws.outQueue.poll(); // Buffer finished. Remove it. buffer = ws.outQueue.peek(); } } while ( buffer != null ); }
if( ws.outQueue.isEmpty() && ws.isFlushAndClose() && ws.getDraft().getRole() == Role.SERVER ) {//
matejdro/PebbleAndroidCommons
src/main/java/com/matejdro/pebblecommons/pebble/PebbleImageToolkit.java
// Path: src/main/java/com/matejdro/pebblecommons/util/LightBitmap.java // public class LightBitmap // { // private int width; // private int height; // private int[] pixels; // // public LightBitmap(Bitmap bitmap) // { // width = bitmap.getWidth(); // height = bitmap.getHeight(); // // pixels = new int[width * height]; // bitmap.getPixels(pixels, 0, width, 0, 0, width, height); // } // // public int getPixel(int x, int y) // { // return pixels[y * width + x]; // } // // public void setPixel(int x, int y, int pixel) // { // pixels[y * width + x] = pixel; // } // // public int getWidth() // { // return width; // } // // public int getHeight() // { // return height; // } // // public Bitmap toBitmap() // { // Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); // bitmap.setPixels(pixels, 0, width, 0, 0, width, height); // return bitmap; // } // }
import android.graphics.Bitmap; import android.graphics.Color; import android.support.annotation.ColorInt; import com.matejdro.pebblecommons.util.LightBitmap; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.util.HashMap; import ar.com.hjg.pngj.ImageInfo; import ar.com.hjg.pngj.ImageLineByte; import ar.com.hjg.pngj.PngWriter; import ar.com.hjg.pngj.chunks.PngChunkBKGD; import ar.com.hjg.pngj.chunks.PngChunkPLTE; import ar.com.hjg.pngj.chunks.PngChunkTRNS;
{ newWidth = originalWidth * newHeight / originalHeight; } return Bitmap.createScaledBitmap(original, newWidth, newHeight, filter); } public static Bitmap resizeAndCrop(Bitmap original, int newWidth, int newHeight, boolean filter) { int originalWidth = original.getWidth(); int originalHeight = original.getHeight(); int originalNewWidth = newWidth; int originalNewHeight = newHeight; if (newWidth / (float) originalWidth < newHeight / (float) originalHeight) { newWidth = originalWidth * newHeight / originalHeight; } else { newHeight = originalHeight * newWidth / originalWidth; } Bitmap scaledBitmap = Bitmap.createScaledBitmap(original, newWidth, newHeight, filter); return Bitmap.createBitmap(scaledBitmap, (newWidth - originalNewWidth) / 2, (newHeight - originalNewHeight) / 2, originalNewWidth, originalNewHeight, null, filter); } public static Bitmap multiplyBrightness(Bitmap original, float multiplier) {
// Path: src/main/java/com/matejdro/pebblecommons/util/LightBitmap.java // public class LightBitmap // { // private int width; // private int height; // private int[] pixels; // // public LightBitmap(Bitmap bitmap) // { // width = bitmap.getWidth(); // height = bitmap.getHeight(); // // pixels = new int[width * height]; // bitmap.getPixels(pixels, 0, width, 0, 0, width, height); // } // // public int getPixel(int x, int y) // { // return pixels[y * width + x]; // } // // public void setPixel(int x, int y, int pixel) // { // pixels[y * width + x] = pixel; // } // // public int getWidth() // { // return width; // } // // public int getHeight() // { // return height; // } // // public Bitmap toBitmap() // { // Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); // bitmap.setPixels(pixels, 0, width, 0, 0, width, height); // return bitmap; // } // } // Path: src/main/java/com/matejdro/pebblecommons/pebble/PebbleImageToolkit.java import android.graphics.Bitmap; import android.graphics.Color; import android.support.annotation.ColorInt; import com.matejdro.pebblecommons.util.LightBitmap; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.util.HashMap; import ar.com.hjg.pngj.ImageInfo; import ar.com.hjg.pngj.ImageLineByte; import ar.com.hjg.pngj.PngWriter; import ar.com.hjg.pngj.chunks.PngChunkBKGD; import ar.com.hjg.pngj.chunks.PngChunkPLTE; import ar.com.hjg.pngj.chunks.PngChunkTRNS; { newWidth = originalWidth * newHeight / originalHeight; } return Bitmap.createScaledBitmap(original, newWidth, newHeight, filter); } public static Bitmap resizeAndCrop(Bitmap original, int newWidth, int newHeight, boolean filter) { int originalWidth = original.getWidth(); int originalHeight = original.getHeight(); int originalNewWidth = newWidth; int originalNewHeight = newHeight; if (newWidth / (float) originalWidth < newHeight / (float) originalHeight) { newWidth = originalWidth * newHeight / originalHeight; } else { newHeight = originalHeight * newWidth / originalWidth; } Bitmap scaledBitmap = Bitmap.createScaledBitmap(original, newWidth, newHeight, filter); return Bitmap.createBitmap(scaledBitmap, (newWidth - originalNewWidth) / 2, (newHeight - originalNewHeight) / 2, originalNewWidth, originalNewHeight, null, filter); } public static Bitmap multiplyBrightness(Bitmap original, float multiplier) {
LightBitmap lightBitmap = new LightBitmap(original);
matejdro/PebbleAndroidCommons
src/main/java/org/java_websocket/drafts/Draft.java
// Path: src/main/java/org/java_websocket/WebSocket.java // public enum Role { // CLIENT, SERVER // } // // Path: src/main/java/org/java_websocket/framing/CloseFrame.java // public interface CloseFrame extends Framedata { // /** // * indicates a normal closure, meaning whatever purpose the // * connection was established for has been fulfilled. // */ // public static final int NORMAL = 1000; // /** // * 1001 indicates that an endpoint is "going away", such as a server // * going down, or a browser having navigated away from a page. // */ // public static final int GOING_AWAY = 1001; // /** // * 1002 indicates that an endpoint is terminating the connection due // * to a protocol error. // */ // public static final int PROTOCOL_ERROR = 1002; // /** // * 1003 indicates that an endpoint is terminating the connection // * because it has received a type of data it cannot accept (e.g. an // * endpoint that understands only text data MAY send this if it // * receives a binary message). // */ // public static final int REFUSE = 1003; // /*1004: Reserved. The specific meaning might be defined in the future.*/ // /** // * 1005 is a reserved value and MUST NOT be set as a status code in a // * Close control frame by an endpoint. It is designated for use in // * applications expecting a status code to indicate that no status // * code was actually present. // */ // public static final int NOCODE = 1005; // /** // * 1006 is a reserved value and MUST NOT be set as a status code in a // * Close control frame by an endpoint. It is designated for use in // * applications expecting a status code to indicate that the // * connection was closed abnormally, e.g. without sending or // * receiving a Close control frame. // */ // public static final int ABNORMAL_CLOSE = 1006; // /** // * 1007 indicates that an endpoint is terminating the connection // * because it has received data within a message that was not // * consistent with the type of the message (e.g., non-UTF-8 [RFC3629] // * data within a text message). // */ // public static final int NO_UTF8 = 1007; // /** // * 1008 indicates that an endpoint is terminating the connection // * because it has received a message that violates its policy. This // * is a generic status code that can be returned when there is no // * other more suitable status code (e.g. 1003 or 1009), or if there // * is a need to hide specific details about the policy. // */ // public static final int POLICY_VALIDATION = 1008; // /** // * 1009 indicates that an endpoint is terminating the connection // * because it has received a message which is too big for it to // * process. // */ // public static final int TOOBIG = 1009; // /** // * 1010 indicates that an endpoint (client) is terminating the // * connection because it has expected the server to negotiate one or // * more extension, but the server didn't return them in the response // * message of the WebSocket handshake. The list of extensions which // * are needed SHOULD appear in the /reason/ part of the Close frame. // * Note that this status code is not used by the server, because it // * can fail the WebSocket handshake instead. // */ // public static final int EXTENSION = 1010; // /** // * 1011 indicates that a server is terminating the connection because // * it encountered an unexpected condition that prevented it from // * fulfilling the request. // **/ // public static final int UNEXPECTED_CONDITION = 1011; // /** // * 1015 is a reserved value and MUST NOT be set as a status code in a // * Close control frame by an endpoint. It is designated for use in // * applications expecting a status code to indicate that the // * connection was closed due to a failure to perform a TLS handshake // * (e.g., the server certificate can't be verified). // **/ // public static final int TLS_ERROR = 1015; // // /** The connection had never been established */ // public static final int NEVER_CONNECTED = -1; // public static final int BUGGYCLOSE = -2; // public static final int FLASHPOLICY = -3; // // public int getCloseCode() throws InvalidFrameException; // public String getMessage() throws InvalidDataException; // }
import org.java_websocket.framing.Framedata; import org.java_websocket.framing.FramedataImpl1; import java.nio.ByteBuffer; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Locale; import org.java_websocket.WebSocket.Role; import org.java_websocket.exceptions.IncompleteHandshakeException; import org.java_websocket.exceptions.InvalidDataException; import org.java_websocket.exceptions.InvalidHandshakeException; import org.java_websocket.exceptions.LimitExedeedException; import org.java_websocket.framing.CloseFrame; import org.java_websocket.framing.FrameBuilder; import org.java_websocket.handshake.ClientHandshake; import org.java_websocket.handshake.ClientHandshakeBuilder; import org.java_websocket.handshake.HandshakeBuilder; import org.java_websocket.handshake.HandshakeImpl1Client; import org.java_websocket.handshake.HandshakeImpl1Server; import org.java_websocket.handshake.Handshakedata; import org.java_websocket.handshake.ServerHandshake; import org.java_websocket.handshake.ServerHandshakeBuilder; import org.java_websocket.util.Charsetfunctions;
package org.java_websocket.drafts; /** * Base class for everything of a websocket specification which is not common such as the way the handshake is read or frames are transfered. **/ public abstract class Draft { public enum HandshakeState { /** Handshake matched this Draft successfully */ MATCHED, /** Handshake is does not match this Draft */ NOT_MATCHED } public enum CloseHandshakeType { NONE, ONEWAY, TWOWAY } public static int MAX_FAME_SIZE = 1000 * 1; public static int INITIAL_FAMESIZE = 64; public static final byte[] FLASH_POLICY_REQUEST = Charsetfunctions.utf8Bytes( "<policy-file-request/>\0" ); /** In some cases the handshake will be parsed different depending on whether */
// Path: src/main/java/org/java_websocket/WebSocket.java // public enum Role { // CLIENT, SERVER // } // // Path: src/main/java/org/java_websocket/framing/CloseFrame.java // public interface CloseFrame extends Framedata { // /** // * indicates a normal closure, meaning whatever purpose the // * connection was established for has been fulfilled. // */ // public static final int NORMAL = 1000; // /** // * 1001 indicates that an endpoint is "going away", such as a server // * going down, or a browser having navigated away from a page. // */ // public static final int GOING_AWAY = 1001; // /** // * 1002 indicates that an endpoint is terminating the connection due // * to a protocol error. // */ // public static final int PROTOCOL_ERROR = 1002; // /** // * 1003 indicates that an endpoint is terminating the connection // * because it has received a type of data it cannot accept (e.g. an // * endpoint that understands only text data MAY send this if it // * receives a binary message). // */ // public static final int REFUSE = 1003; // /*1004: Reserved. The specific meaning might be defined in the future.*/ // /** // * 1005 is a reserved value and MUST NOT be set as a status code in a // * Close control frame by an endpoint. It is designated for use in // * applications expecting a status code to indicate that no status // * code was actually present. // */ // public static final int NOCODE = 1005; // /** // * 1006 is a reserved value and MUST NOT be set as a status code in a // * Close control frame by an endpoint. It is designated for use in // * applications expecting a status code to indicate that the // * connection was closed abnormally, e.g. without sending or // * receiving a Close control frame. // */ // public static final int ABNORMAL_CLOSE = 1006; // /** // * 1007 indicates that an endpoint is terminating the connection // * because it has received data within a message that was not // * consistent with the type of the message (e.g., non-UTF-8 [RFC3629] // * data within a text message). // */ // public static final int NO_UTF8 = 1007; // /** // * 1008 indicates that an endpoint is terminating the connection // * because it has received a message that violates its policy. This // * is a generic status code that can be returned when there is no // * other more suitable status code (e.g. 1003 or 1009), or if there // * is a need to hide specific details about the policy. // */ // public static final int POLICY_VALIDATION = 1008; // /** // * 1009 indicates that an endpoint is terminating the connection // * because it has received a message which is too big for it to // * process. // */ // public static final int TOOBIG = 1009; // /** // * 1010 indicates that an endpoint (client) is terminating the // * connection because it has expected the server to negotiate one or // * more extension, but the server didn't return them in the response // * message of the WebSocket handshake. The list of extensions which // * are needed SHOULD appear in the /reason/ part of the Close frame. // * Note that this status code is not used by the server, because it // * can fail the WebSocket handshake instead. // */ // public static final int EXTENSION = 1010; // /** // * 1011 indicates that a server is terminating the connection because // * it encountered an unexpected condition that prevented it from // * fulfilling the request. // **/ // public static final int UNEXPECTED_CONDITION = 1011; // /** // * 1015 is a reserved value and MUST NOT be set as a status code in a // * Close control frame by an endpoint. It is designated for use in // * applications expecting a status code to indicate that the // * connection was closed due to a failure to perform a TLS handshake // * (e.g., the server certificate can't be verified). // **/ // public static final int TLS_ERROR = 1015; // // /** The connection had never been established */ // public static final int NEVER_CONNECTED = -1; // public static final int BUGGYCLOSE = -2; // public static final int FLASHPOLICY = -3; // // public int getCloseCode() throws InvalidFrameException; // public String getMessage() throws InvalidDataException; // } // Path: src/main/java/org/java_websocket/drafts/Draft.java import org.java_websocket.framing.Framedata; import org.java_websocket.framing.FramedataImpl1; import java.nio.ByteBuffer; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Locale; import org.java_websocket.WebSocket.Role; import org.java_websocket.exceptions.IncompleteHandshakeException; import org.java_websocket.exceptions.InvalidDataException; import org.java_websocket.exceptions.InvalidHandshakeException; import org.java_websocket.exceptions.LimitExedeedException; import org.java_websocket.framing.CloseFrame; import org.java_websocket.framing.FrameBuilder; import org.java_websocket.handshake.ClientHandshake; import org.java_websocket.handshake.ClientHandshakeBuilder; import org.java_websocket.handshake.HandshakeBuilder; import org.java_websocket.handshake.HandshakeImpl1Client; import org.java_websocket.handshake.HandshakeImpl1Server; import org.java_websocket.handshake.Handshakedata; import org.java_websocket.handshake.ServerHandshake; import org.java_websocket.handshake.ServerHandshakeBuilder; import org.java_websocket.util.Charsetfunctions; package org.java_websocket.drafts; /** * Base class for everything of a websocket specification which is not common such as the way the handshake is read or frames are transfered. **/ public abstract class Draft { public enum HandshakeState { /** Handshake matched this Draft successfully */ MATCHED, /** Handshake is does not match this Draft */ NOT_MATCHED } public enum CloseHandshakeType { NONE, ONEWAY, TWOWAY } public static int MAX_FAME_SIZE = 1000 * 1; public static int INITIAL_FAMESIZE = 64; public static final byte[] FLASH_POLICY_REQUEST = Charsetfunctions.utf8Bytes( "<policy-file-request/>\0" ); /** In some cases the handshake will be parsed different depending on whether */
protected Role role = null;
matejdro/PebbleAndroidCommons
src/main/java/com/matejdro/pebblecommons/messages/TimeVoiceProvider.java
// Path: src/main/java/com/matejdro/pebblecommons/notification/NotificationCenterExtender.java // public class NotificationCenterExtender implements NotificationCompat.Extender // { // private static final String EXTRA_NC_EXTENSIONS = "com.matejdro.pebblenotificationcenter.NOTIFICATION_EXTENSIONS"; // private static final String KEY_DISABLE_NC_NOTIFICATION = "disableNCNotification"; // // public NotificationCenterExtender() // { // // } // // public NotificationCenterExtender(Notification notification) // { // Bundle extras = NotificationCompat.getExtras(notification); // Bundle extenderBundle = extras != null ? extras.getBundle(EXTRA_NC_EXTENSIONS) : null; // if (extenderBundle != null) // { // disableNCNotification = extenderBundle.getBoolean(KEY_DISABLE_NC_NOTIFICATION); // } // } // // private boolean disableNCNotification = false; // // public boolean isNCNotificationDisabled() // { // return disableNCNotification; // } // // public NotificationCenterExtender setDisableNCNotification(boolean disableNCNotification) // { // this.disableNCNotification = disableNCNotification; // // return this; // } // // @Override // public NotificationCompat.Builder extend(NotificationCompat.Builder builder) // { // Bundle extensionBundle = new Bundle(); // extensionBundle.putBoolean(KEY_DISABLE_NC_NOTIFICATION, disableNCNotification); // // builder.getExtras().putBundle(EXTRA_NC_EXTENSIONS, extensionBundle); // return null; // } // }
import android.app.Notification; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.RemoteInput; import com.matejdro.pebblecommons.R; import com.matejdro.pebblecommons.notification.NotificationCenterExtender;
public TimeVoiceProvider(Context context) { this.context = context; } @Override public void startRetrievingText(MessageTextProviderListener textListener) { this.textListener = textListener; PendingIntent replyIntent = PendingIntent.getBroadcast(context, 0, new Intent(INTENT_ACTION_TEXT), 0); PendingIntent removeIntent = PendingIntent.getBroadcast(context, 0, new Intent(INTENT_ACTION_REMOVE), PendingIntent.FLAG_UPDATE_CURRENT); RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(context.getString(R.string.voice_prompt_title)).setAllowFreeFormInput(true).build(); NotificationCompat.Action voiceAction = new NotificationCompat.Action.Builder(0, context.getString(R.string.voice_prompt_title), replyIntent).addRemoteInput(remoteInput).build(); // Instruction text is always the same so I need to add random character (usually appears as box) and padding to ensure // that Pebble duplicate filtering won't affect this. char randomCharacter = (char) (System.currentTimeMillis() % Short.MAX_VALUE); long padding = System.currentTimeMillis(); String appName = context.getApplicationInfo().loadLabel(context.getPackageManager()).toString(); String instructions = context.getString(R.string.voice_prompt_instructions, randomCharacter, padding, appName); Notification notification = new NotificationCompat.Builder(context) .setContentTitle(context.getString(R.string.voice_prompt_title)) .setContentText(instructions) .setStyle(new NotificationCompat.BigTextStyle().bigText(instructions)) .setSmallIcon(android.R.drawable.sym_def_app_icon) //Dummy icon to satisfy android notification requiremet .extend(new NotificationCompat.WearableExtender().addAction(voiceAction))
// Path: src/main/java/com/matejdro/pebblecommons/notification/NotificationCenterExtender.java // public class NotificationCenterExtender implements NotificationCompat.Extender // { // private static final String EXTRA_NC_EXTENSIONS = "com.matejdro.pebblenotificationcenter.NOTIFICATION_EXTENSIONS"; // private static final String KEY_DISABLE_NC_NOTIFICATION = "disableNCNotification"; // // public NotificationCenterExtender() // { // // } // // public NotificationCenterExtender(Notification notification) // { // Bundle extras = NotificationCompat.getExtras(notification); // Bundle extenderBundle = extras != null ? extras.getBundle(EXTRA_NC_EXTENSIONS) : null; // if (extenderBundle != null) // { // disableNCNotification = extenderBundle.getBoolean(KEY_DISABLE_NC_NOTIFICATION); // } // } // // private boolean disableNCNotification = false; // // public boolean isNCNotificationDisabled() // { // return disableNCNotification; // } // // public NotificationCenterExtender setDisableNCNotification(boolean disableNCNotification) // { // this.disableNCNotification = disableNCNotification; // // return this; // } // // @Override // public NotificationCompat.Builder extend(NotificationCompat.Builder builder) // { // Bundle extensionBundle = new Bundle(); // extensionBundle.putBoolean(KEY_DISABLE_NC_NOTIFICATION, disableNCNotification); // // builder.getExtras().putBundle(EXTRA_NC_EXTENSIONS, extensionBundle); // return null; // } // } // Path: src/main/java/com/matejdro/pebblecommons/messages/TimeVoiceProvider.java import android.app.Notification; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.RemoteInput; import com.matejdro.pebblecommons.R; import com.matejdro.pebblecommons.notification.NotificationCenterExtender; public TimeVoiceProvider(Context context) { this.context = context; } @Override public void startRetrievingText(MessageTextProviderListener textListener) { this.textListener = textListener; PendingIntent replyIntent = PendingIntent.getBroadcast(context, 0, new Intent(INTENT_ACTION_TEXT), 0); PendingIntent removeIntent = PendingIntent.getBroadcast(context, 0, new Intent(INTENT_ACTION_REMOVE), PendingIntent.FLAG_UPDATE_CURRENT); RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(context.getString(R.string.voice_prompt_title)).setAllowFreeFormInput(true).build(); NotificationCompat.Action voiceAction = new NotificationCompat.Action.Builder(0, context.getString(R.string.voice_prompt_title), replyIntent).addRemoteInput(remoteInput).build(); // Instruction text is always the same so I need to add random character (usually appears as box) and padding to ensure // that Pebble duplicate filtering won't affect this. char randomCharacter = (char) (System.currentTimeMillis() % Short.MAX_VALUE); long padding = System.currentTimeMillis(); String appName = context.getApplicationInfo().loadLabel(context.getPackageManager()).toString(); String instructions = context.getString(R.string.voice_prompt_instructions, randomCharacter, padding, appName); Notification notification = new NotificationCompat.Builder(context) .setContentTitle(context.getString(R.string.voice_prompt_title)) .setContentText(instructions) .setStyle(new NotificationCompat.BigTextStyle().bigText(instructions)) .setSmallIcon(android.R.drawable.sym_def_app_icon) //Dummy icon to satisfy android notification requiremet .extend(new NotificationCompat.WearableExtender().addAction(voiceAction))
.extend(new NotificationCenterExtender().setDisableNCNotification(true)) //Prevent NC from displaying this notification
christianhujer/jcardmock
src/main/java/javacard/framework/APDUException.java
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // }
import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances;
package javacard.framework; public class APDUException extends CardRuntimeException { public static final short BAD_LENGTH = 3; public static final short BUFFER_BOUNDS = 2; public static final short ILLEGAL_USE = 1; public static final short IO_ERROR = 4; public static final short NO_T0_GETRESPONSE = 170; public static final short NO_T0_REISSUE = 172; public static final short T1_IFD_ABORT = 171; public APDUException(final short reason) { super(reason); } public static void throwIt(final short reason) throws APDUException {
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // } // Path: src/main/java/javacard/framework/APDUException.java import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances; package javacard.framework; public class APDUException extends CardRuntimeException { public static final short BAD_LENGTH = 3; public static final short BUFFER_BOUNDS = 2; public static final short ILLEGAL_USE = 1; public static final short IO_ERROR = 4; public static final short NO_T0_GETRESPONSE = 170; public static final short NO_T0_REISSUE = 172; public static final short T1_IFD_ABORT = 171; public APDUException(final short reason) { super(reason); } public static void throwIt(final short reason) throws APDUException {
RuntimeEnvironmentOwnedExceptionInstances.throwIt(APDUException.class, reason);
christianhujer/jcardmock
src/main/java/javacard/framework/UserException.java
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // }
import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances;
package javacard.framework; public class UserException extends CardException { public UserException(final short reason) { super(reason); } public UserException() { this((short) 0); } public static void throwIt(final short reason) throws UserException {
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // } // Path: src/main/java/javacard/framework/UserException.java import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances; package javacard.framework; public class UserException extends CardException { public UserException(final short reason) { super(reason); } public UserException() { this((short) 0); } public static void throwIt(final short reason) throws UserException {
RuntimeEnvironmentOwnedExceptionInstances.throwIt(UserException.class, reason);
christianhujer/jcardmock
src/main/java/javacard/framework/CardException.java
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // }
import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances;
package javacard.framework; public class CardException extends Exception { private short reason; public CardException(final short reason) { this.reason = reason; } public void setReason(final short reason) { this.reason = reason; } public static void throwIt(final short reason) throws CardException {
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // } // Path: src/main/java/javacard/framework/CardException.java import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances; package javacard.framework; public class CardException extends Exception { private short reason; public CardException(final short reason) { this.reason = reason; } public void setReason(final short reason) { this.reason = reason; } public static void throwIt(final short reason) throws CardException {
RuntimeEnvironmentOwnedExceptionInstances.throwIt(CardException.class, reason);
christianhujer/jcardmock
src/main/java/javacard/security/CryptoException.java
// Path: src/main/java/javacard/framework/CardRuntimeException.java // public class CardRuntimeException extends RuntimeException { // private short reason; // // public CardRuntimeException(final short reason) { // this.reason = reason; // } // // public void setReason(final short reason) { // this.reason = reason; // } // // public static void throwIt(final short reason) throws CardRuntimeException { // RuntimeEnvironmentOwnedExceptionInstances.throwIt(CardRuntimeException.class, reason); // } // // public short getReason() { // return reason; // } // } // // Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // }
import javacard.framework.CardRuntimeException; import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances;
package javacard.security; public class CryptoException extends CardRuntimeException { public static final short ILLEGAL_USE = 5; public static final short ILLEGAL_VALUE = 1; public static final short INVALID_INIT = 4; public static final short NO_SUCH_ALGORITHM = 3; public static final short UNINITIALIZED_KEY = 2; public CryptoException(final short reason) { super(reason); } public static void throwIt(final short reason) throws CryptoException {
// Path: src/main/java/javacard/framework/CardRuntimeException.java // public class CardRuntimeException extends RuntimeException { // private short reason; // // public CardRuntimeException(final short reason) { // this.reason = reason; // } // // public void setReason(final short reason) { // this.reason = reason; // } // // public static void throwIt(final short reason) throws CardRuntimeException { // RuntimeEnvironmentOwnedExceptionInstances.throwIt(CardRuntimeException.class, reason); // } // // public short getReason() { // return reason; // } // } // // Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // } // Path: src/main/java/javacard/security/CryptoException.java import javacard.framework.CardRuntimeException; import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances; package javacard.security; public class CryptoException extends CardRuntimeException { public static final short ILLEGAL_USE = 5; public static final short ILLEGAL_VALUE = 1; public static final short INVALID_INIT = 4; public static final short NO_SUCH_ALGORITHM = 3; public static final short UNINITIALIZED_KEY = 2; public CryptoException(final short reason) { super(reason); } public static void throwIt(final short reason) throws CryptoException {
RuntimeEnvironmentOwnedExceptionInstances.throwIt(CryptoException.class, reason);
christianhujer/jcardmock
src/main/java/javacard/framework/TransactionException.java
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // }
import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances;
package javacard.framework; public class TransactionException extends CardRuntimeException { public static final short BUFFER_FULL = 3; public static final short ILLEGAL_USE = 5; public static final short IN_PROGRESS = 1; public static final short INTERNAL_FAILURE = 4; public static final short NOT_IN_PROGRESS = 2; public TransactionException(final short reason) { super(reason); } public static void throwIt(final short reason) throws TransactionException {
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // } // Path: src/main/java/javacard/framework/TransactionException.java import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances; package javacard.framework; public class TransactionException extends CardRuntimeException { public static final short BUFFER_FULL = 3; public static final short ILLEGAL_USE = 5; public static final short IN_PROGRESS = 1; public static final short INTERNAL_FAILURE = 4; public static final short NOT_IN_PROGRESS = 2; public TransactionException(final short reason) { super(reason); } public static void throwIt(final short reason) throws TransactionException {
RuntimeEnvironmentOwnedExceptionInstances.throwIt(TransactionException.class, reason);
christianhujer/jcardmock
src/main/java/javacard/framework/service/ServiceException.java
// Path: src/main/java/javacard/framework/CardRuntimeException.java // public class CardRuntimeException extends RuntimeException { // private short reason; // // public CardRuntimeException(final short reason) { // this.reason = reason; // } // // public void setReason(final short reason) { // this.reason = reason; // } // // public static void throwIt(final short reason) throws CardRuntimeException { // RuntimeEnvironmentOwnedExceptionInstances.throwIt(CardRuntimeException.class, reason); // } // // public short getReason() { // return reason; // } // } // // Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // }
import javacard.framework.CardRuntimeException; import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances;
package javacard.framework.service; public class ServiceException extends CardRuntimeException { public static final short CANNOT_ACCESS_IN_COMMAND = 4; public static final short CANNOT_ACCESS_OUT_COMMAND = 5; public static final short COMMAND_DATA_TOO_LONG = 3; public static final short COMMAND_IS_FINISHED = 6; public static final short DISPATCH_TABLE_FULL = 2; public static final short ILLEGAL_PARAM = 1; public static final short REMOTE_OBJECT_NOT_EXPORTED = 7; public ServiceException(final short reason) { super(reason); } public static void throwIt(final short reason) throws ServiceException {
// Path: src/main/java/javacard/framework/CardRuntimeException.java // public class CardRuntimeException extends RuntimeException { // private short reason; // // public CardRuntimeException(final short reason) { // this.reason = reason; // } // // public void setReason(final short reason) { // this.reason = reason; // } // // public static void throwIt(final short reason) throws CardRuntimeException { // RuntimeEnvironmentOwnedExceptionInstances.throwIt(CardRuntimeException.class, reason); // } // // public short getReason() { // return reason; // } // } // // Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // } // Path: src/main/java/javacard/framework/service/ServiceException.java import javacard.framework.CardRuntimeException; import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances; package javacard.framework.service; public class ServiceException extends CardRuntimeException { public static final short CANNOT_ACCESS_IN_COMMAND = 4; public static final short CANNOT_ACCESS_OUT_COMMAND = 5; public static final short COMMAND_DATA_TOO_LONG = 3; public static final short COMMAND_IS_FINISHED = 6; public static final short DISPATCH_TABLE_FULL = 2; public static final short ILLEGAL_PARAM = 1; public static final short REMOTE_OBJECT_NOT_EXPORTED = 7; public ServiceException(final short reason) { super(reason); } public static void throwIt(final short reason) throws ServiceException {
RuntimeEnvironmentOwnedExceptionInstances.throwIt(ServiceException.class, reason);
christianhujer/jcardmock
src/main/java/javacard/framework/SystemException.java
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // }
import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances;
package javacard.framework; public class SystemException extends CardRuntimeException { public static final short ILLEGAL_AID = 4; public static final short ILLEGAL_TRANSIENT = 3; public static final short ILLEGAL_USE = 6; public static final short ILLEGAL_VALUE = 1; public static final short NO_RESOURCE = 5; public static final short NO_TRANSIENT_SPACE = 2; public SystemException(final short reason) { super(reason); } public static void throwIt(final short reason) throws SystemException {
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // } // Path: src/main/java/javacard/framework/SystemException.java import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances; package javacard.framework; public class SystemException extends CardRuntimeException { public static final short ILLEGAL_AID = 4; public static final short ILLEGAL_TRANSIENT = 3; public static final short ILLEGAL_USE = 6; public static final short ILLEGAL_VALUE = 1; public static final short NO_RESOURCE = 5; public static final short NO_TRANSIENT_SPACE = 2; public SystemException(final short reason) { super(reason); } public static void throwIt(final short reason) throws SystemException {
RuntimeEnvironmentOwnedExceptionInstances.throwIt(SystemException.class, reason);
christianhujer/jcardmock
src/main/java/javacard/framework/PINException.java
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // }
import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances;
package javacard.framework; public class PINException extends CardRuntimeException { public static final short ILLEGAL_VALUE = 1; public PINException(final short reason) { super(reason); } public static void throwIt(final short reason) throws PINException {
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // } // Path: src/main/java/javacard/framework/PINException.java import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances; package javacard.framework; public class PINException extends CardRuntimeException { public static final short ILLEGAL_VALUE = 1; public PINException(final short reason) { super(reason); } public static void throwIt(final short reason) throws PINException {
RuntimeEnvironmentOwnedExceptionInstances.throwIt(PINException.class, reason);
christianhujer/jcardmock
src/main/java/javacard/framework/ISOException.java
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // }
import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances;
package javacard.framework; public class ISOException extends CardRuntimeException { public ISOException(final short reason) { super(reason); } public static void throwIt(final short reason) throws ISOException {
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // } // Path: src/main/java/javacard/framework/ISOException.java import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances; package javacard.framework; public class ISOException extends CardRuntimeException { public ISOException(final short reason) { super(reason); } public static void throwIt(final short reason) throws ISOException {
RuntimeEnvironmentOwnedExceptionInstances.throwIt(ISOException.class, reason);
christianhujer/jcardmock
src/main/java/javacard/framework/CardRuntimeException.java
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // }
import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances;
package javacard.framework; public class CardRuntimeException extends RuntimeException { private short reason; public CardRuntimeException(final short reason) { this.reason = reason; } public void setReason(final short reason) { this.reason = reason; } public static void throwIt(final short reason) throws CardRuntimeException {
// Path: src/main/java/jcardmock/os/RuntimeEnvironmentOwnedExceptionInstances.java // public class RuntimeEnvironmentOwnedExceptionInstances { // private static Map<Class<? extends Exception>, Exception> runtimeEnvironmentOwnedExceptionInstances = new HashMap<>(); // public static <E extends Exception> void throwIt(final Class<E> exceptionClass, final short reason) throws E { // final E exception = (E) runtimeEnvironmentOwnedExceptionInstances.computeIfAbsent(exceptionClass, RuntimeEnvironmentOwnedExceptionInstances::createNew); // setReason(exception, reason); // exception.fillInStackTrace(); // throw exception; // } // // private static void setReason(final Exception exception, final short reason) { // try { // final Method setReason = exception.getClass().getMethod("setReason", Short.TYPE); // setReason.invoke(exception, reason); // } catch (final InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // // private static Exception createNew(final Class<? extends Exception> aClass) { // try { // final Constructor<? extends Exception> constructor = aClass.getConstructor(Short.TYPE); // return constructor.newInstance((short) 0x0000); // } catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { // throw new AssertionError(e); // } // } // } // Path: src/main/java/javacard/framework/CardRuntimeException.java import jcardmock.os.RuntimeEnvironmentOwnedExceptionInstances; package javacard.framework; public class CardRuntimeException extends RuntimeException { private short reason; public CardRuntimeException(final short reason) { this.reason = reason; } public void setReason(final short reason) { this.reason = reason; } public static void throwIt(final short reason) throws CardRuntimeException {
RuntimeEnvironmentOwnedExceptionInstances.throwIt(CardRuntimeException.class, reason);
andidev/spring-bootstrap-enterprise
src/main/java/org/andidev/applicationname/config/interceptor/TimeZoneInterceptor.java
// Path: src/main/java/org/andidev/applicationname/entity/User.java // @Entity // @NoArgsConstructor(access = PROTECTED) // @RequiredArgsConstructor // @Setter // @Getter // public class User extends IdEntity implements UserDetails, Serializable { // // @Column(unique = true) // @NonNull // private String username; // @NonNull // private String password; // private String firstName; // private String lastName; // private String email; // private boolean accountNonExpired; // private boolean accountNonLocked; // private boolean credentialsNonExpired; // private boolean enabled; // private Period automaticLogoutTime; // private Locale locale; // private DateTimeZone timeZone; // private String dateFormat = "yyyy/MM/dd"; // private String timeFormat = "HH.mm"; // @ElementCollection(targetClass = Role.class, fetch = EAGER) // @Enumerated(STRING) // private Set<Role> userRoles = EnumSet.noneOf(Role.class); // @ManyToMany(mappedBy = "users", fetch = EAGER) // private Set<Group> groups = new HashSet(); // @OneToMany(fetch = EAGER) // private Set<PreferenceValue> preferenceValues = new HashSet(); // // public Set<Role> getRoles() { // Set<Role> roles = EnumSet.noneOf(Role.class); // roles.addAll(getUserRoles()); // roles.addAll(getGroupRoles()); // return roles; // } // // private Set<Role> getGroupRoles() { // Set<Role> roles = EnumSet.noneOf(Role.class); // for (Group group : getGroups()) { // roles.addAll(group.getGroupRoles()); // } // return roles; // } // // @Override // public Collection<? extends GrantedAuthority> getAuthorities() { // Set<GrantedAuthority> grantedAuthorities = new LinkedHashSet<>(); // for (Role role : getRoles()) { // grantedAuthorities.add(new SimpleGrantedAuthority(role.name())); // } // return grantedAuthorities; // } // } // // Path: src/main/java/org/andidev/applicationname/util/StringUtils.java // public static String quote(String text) { // return "\"" + text + "\""; // }
import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.entity.User; import static org.andidev.applicationname.util.StringUtils.quote; import org.joda.time.DateTimeZone; import org.springframework.format.datetime.joda.JodaTimeContext; import org.springframework.format.datetime.joda.JodaTimeContextHolder;
package org.andidev.applicationname.config.interceptor; @Slf4j public class TimeZoneInterceptor extends ParameterInterceptor<DateTimeZone> { public TimeZoneInterceptor(String parameterName) { super(parameterName); } @Override protected String printParameter(DateTimeZone timeZone) { return timeZone.getID(); } @Override protected DateTimeZone parseParameter(String timeZone) { try { return DateTimeZone.forID(timeZone); } catch (IllegalArgumentException e) {
// Path: src/main/java/org/andidev/applicationname/entity/User.java // @Entity // @NoArgsConstructor(access = PROTECTED) // @RequiredArgsConstructor // @Setter // @Getter // public class User extends IdEntity implements UserDetails, Serializable { // // @Column(unique = true) // @NonNull // private String username; // @NonNull // private String password; // private String firstName; // private String lastName; // private String email; // private boolean accountNonExpired; // private boolean accountNonLocked; // private boolean credentialsNonExpired; // private boolean enabled; // private Period automaticLogoutTime; // private Locale locale; // private DateTimeZone timeZone; // private String dateFormat = "yyyy/MM/dd"; // private String timeFormat = "HH.mm"; // @ElementCollection(targetClass = Role.class, fetch = EAGER) // @Enumerated(STRING) // private Set<Role> userRoles = EnumSet.noneOf(Role.class); // @ManyToMany(mappedBy = "users", fetch = EAGER) // private Set<Group> groups = new HashSet(); // @OneToMany(fetch = EAGER) // private Set<PreferenceValue> preferenceValues = new HashSet(); // // public Set<Role> getRoles() { // Set<Role> roles = EnumSet.noneOf(Role.class); // roles.addAll(getUserRoles()); // roles.addAll(getGroupRoles()); // return roles; // } // // private Set<Role> getGroupRoles() { // Set<Role> roles = EnumSet.noneOf(Role.class); // for (Group group : getGroups()) { // roles.addAll(group.getGroupRoles()); // } // return roles; // } // // @Override // public Collection<? extends GrantedAuthority> getAuthorities() { // Set<GrantedAuthority> grantedAuthorities = new LinkedHashSet<>(); // for (Role role : getRoles()) { // grantedAuthorities.add(new SimpleGrantedAuthority(role.name())); // } // return grantedAuthorities; // } // } // // Path: src/main/java/org/andidev/applicationname/util/StringUtils.java // public static String quote(String text) { // return "\"" + text + "\""; // } // Path: src/main/java/org/andidev/applicationname/config/interceptor/TimeZoneInterceptor.java import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.entity.User; import static org.andidev.applicationname.util.StringUtils.quote; import org.joda.time.DateTimeZone; import org.springframework.format.datetime.joda.JodaTimeContext; import org.springframework.format.datetime.joda.JodaTimeContextHolder; package org.andidev.applicationname.config.interceptor; @Slf4j public class TimeZoneInterceptor extends ParameterInterceptor<DateTimeZone> { public TimeZoneInterceptor(String parameterName) { super(parameterName); } @Override protected String printParameter(DateTimeZone timeZone) { return timeZone.getID(); } @Override protected DateTimeZone parseParameter(String timeZone) { try { return DateTimeZone.forID(timeZone); } catch (IllegalArgumentException e) {
log.warn("Setting timezone to = " + quote(timeZone) + " by parameter failed, the timezone does not exist. Please use one of the following time zones: " + DateTimeZone.getAvailableIDs());
andidev/spring-bootstrap-enterprise
src/main/java/org/andidev/applicationname/config/interceptor/TimeZoneInterceptor.java
// Path: src/main/java/org/andidev/applicationname/entity/User.java // @Entity // @NoArgsConstructor(access = PROTECTED) // @RequiredArgsConstructor // @Setter // @Getter // public class User extends IdEntity implements UserDetails, Serializable { // // @Column(unique = true) // @NonNull // private String username; // @NonNull // private String password; // private String firstName; // private String lastName; // private String email; // private boolean accountNonExpired; // private boolean accountNonLocked; // private boolean credentialsNonExpired; // private boolean enabled; // private Period automaticLogoutTime; // private Locale locale; // private DateTimeZone timeZone; // private String dateFormat = "yyyy/MM/dd"; // private String timeFormat = "HH.mm"; // @ElementCollection(targetClass = Role.class, fetch = EAGER) // @Enumerated(STRING) // private Set<Role> userRoles = EnumSet.noneOf(Role.class); // @ManyToMany(mappedBy = "users", fetch = EAGER) // private Set<Group> groups = new HashSet(); // @OneToMany(fetch = EAGER) // private Set<PreferenceValue> preferenceValues = new HashSet(); // // public Set<Role> getRoles() { // Set<Role> roles = EnumSet.noneOf(Role.class); // roles.addAll(getUserRoles()); // roles.addAll(getGroupRoles()); // return roles; // } // // private Set<Role> getGroupRoles() { // Set<Role> roles = EnumSet.noneOf(Role.class); // for (Group group : getGroups()) { // roles.addAll(group.getGroupRoles()); // } // return roles; // } // // @Override // public Collection<? extends GrantedAuthority> getAuthorities() { // Set<GrantedAuthority> grantedAuthorities = new LinkedHashSet<>(); // for (Role role : getRoles()) { // grantedAuthorities.add(new SimpleGrantedAuthority(role.name())); // } // return grantedAuthorities; // } // } // // Path: src/main/java/org/andidev/applicationname/util/StringUtils.java // public static String quote(String text) { // return "\"" + text + "\""; // }
import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.entity.User; import static org.andidev.applicationname.util.StringUtils.quote; import org.joda.time.DateTimeZone; import org.springframework.format.datetime.joda.JodaTimeContext; import org.springframework.format.datetime.joda.JodaTimeContextHolder;
package org.andidev.applicationname.config.interceptor; @Slf4j public class TimeZoneInterceptor extends ParameterInterceptor<DateTimeZone> { public TimeZoneInterceptor(String parameterName) { super(parameterName); } @Override protected String printParameter(DateTimeZone timeZone) { return timeZone.getID(); } @Override protected DateTimeZone parseParameter(String timeZone) { try { return DateTimeZone.forID(timeZone); } catch (IllegalArgumentException e) { log.warn("Setting timezone to = " + quote(timeZone) + " by parameter failed, the timezone does not exist. Please use one of the following time zones: " + DateTimeZone.getAvailableIDs()); return null; } } @Override
// Path: src/main/java/org/andidev/applicationname/entity/User.java // @Entity // @NoArgsConstructor(access = PROTECTED) // @RequiredArgsConstructor // @Setter // @Getter // public class User extends IdEntity implements UserDetails, Serializable { // // @Column(unique = true) // @NonNull // private String username; // @NonNull // private String password; // private String firstName; // private String lastName; // private String email; // private boolean accountNonExpired; // private boolean accountNonLocked; // private boolean credentialsNonExpired; // private boolean enabled; // private Period automaticLogoutTime; // private Locale locale; // private DateTimeZone timeZone; // private String dateFormat = "yyyy/MM/dd"; // private String timeFormat = "HH.mm"; // @ElementCollection(targetClass = Role.class, fetch = EAGER) // @Enumerated(STRING) // private Set<Role> userRoles = EnumSet.noneOf(Role.class); // @ManyToMany(mappedBy = "users", fetch = EAGER) // private Set<Group> groups = new HashSet(); // @OneToMany(fetch = EAGER) // private Set<PreferenceValue> preferenceValues = new HashSet(); // // public Set<Role> getRoles() { // Set<Role> roles = EnumSet.noneOf(Role.class); // roles.addAll(getUserRoles()); // roles.addAll(getGroupRoles()); // return roles; // } // // private Set<Role> getGroupRoles() { // Set<Role> roles = EnumSet.noneOf(Role.class); // for (Group group : getGroups()) { // roles.addAll(group.getGroupRoles()); // } // return roles; // } // // @Override // public Collection<? extends GrantedAuthority> getAuthorities() { // Set<GrantedAuthority> grantedAuthorities = new LinkedHashSet<>(); // for (Role role : getRoles()) { // grantedAuthorities.add(new SimpleGrantedAuthority(role.name())); // } // return grantedAuthorities; // } // } // // Path: src/main/java/org/andidev/applicationname/util/StringUtils.java // public static String quote(String text) { // return "\"" + text + "\""; // } // Path: src/main/java/org/andidev/applicationname/config/interceptor/TimeZoneInterceptor.java import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.entity.User; import static org.andidev.applicationname.util.StringUtils.quote; import org.joda.time.DateTimeZone; import org.springframework.format.datetime.joda.JodaTimeContext; import org.springframework.format.datetime.joda.JodaTimeContextHolder; package org.andidev.applicationname.config.interceptor; @Slf4j public class TimeZoneInterceptor extends ParameterInterceptor<DateTimeZone> { public TimeZoneInterceptor(String parameterName) { super(parameterName); } @Override protected String printParameter(DateTimeZone timeZone) { return timeZone.getID(); } @Override protected DateTimeZone parseParameter(String timeZone) { try { return DateTimeZone.forID(timeZone); } catch (IllegalArgumentException e) { log.warn("Setting timezone to = " + quote(timeZone) + " by parameter failed, the timezone does not exist. Please use one of the following time zones: " + DateTimeZone.getAvailableIDs()); return null; } } @Override
protected DateTimeZone getParameterFromUserSettings(User user) {
andidev/spring-bootstrap-enterprise
src/main/java/org/andidev/applicationname/config/springsecurity/LogoutListener.java
// Path: src/main/java/org/andidev/applicationname/config/logging/MDC.java // public class MDC { // // public static void putSession(String session) { // org.slf4j.MDC.put("session", left(session, 9)); // } // // public static void removeSession() { // org.slf4j.MDC.remove("session"); // } // // public static void putUsername(String username) { // org.slf4j.MDC.put("username", username); // } // // public static void removeUsername() { // org.slf4j.MDC.remove("username"); // } // } // // Path: src/main/java/org/andidev/applicationname/util/StringUtils.java // public static String quote(String text) { // return "\"" + text + "\""; // }
import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.config.logging.MDC; import static org.andidev.applicationname.util.StringUtils.quote; import org.springframework.context.ApplicationListener; import org.springframework.security.core.session.SessionDestroyedEvent; import org.springframework.security.web.session.HttpSessionDestroyedEvent; import org.springframework.stereotype.Component;
package org.andidev.applicationname.config.springsecurity; @Slf4j @Component public class LogoutListener implements ApplicationListener<SessionDestroyedEvent> { @Override public void onApplicationEvent(SessionDestroyedEvent event) { String sessionId = (String) ((HttpSessionDestroyedEvent) event).getSession().getId(); String username = (String) ((HttpSessionDestroyedEvent) event).getSession().getAttribute("username");
// Path: src/main/java/org/andidev/applicationname/config/logging/MDC.java // public class MDC { // // public static void putSession(String session) { // org.slf4j.MDC.put("session", left(session, 9)); // } // // public static void removeSession() { // org.slf4j.MDC.remove("session"); // } // // public static void putUsername(String username) { // org.slf4j.MDC.put("username", username); // } // // public static void removeUsername() { // org.slf4j.MDC.remove("username"); // } // } // // Path: src/main/java/org/andidev/applicationname/util/StringUtils.java // public static String quote(String text) { // return "\"" + text + "\""; // } // Path: src/main/java/org/andidev/applicationname/config/springsecurity/LogoutListener.java import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.config.logging.MDC; import static org.andidev.applicationname.util.StringUtils.quote; import org.springframework.context.ApplicationListener; import org.springframework.security.core.session.SessionDestroyedEvent; import org.springframework.security.web.session.HttpSessionDestroyedEvent; import org.springframework.stereotype.Component; package org.andidev.applicationname.config.springsecurity; @Slf4j @Component public class LogoutListener implements ApplicationListener<SessionDestroyedEvent> { @Override public void onApplicationEvent(SessionDestroyedEvent event) { String sessionId = (String) ((HttpSessionDestroyedEvent) event).getSession().getId(); String username = (String) ((HttpSessionDestroyedEvent) event).getSession().getAttribute("username");
MDC.putSession(sessionId);
andidev/spring-bootstrap-enterprise
src/main/java/org/andidev/applicationname/config/springsecurity/LogoutListener.java
// Path: src/main/java/org/andidev/applicationname/config/logging/MDC.java // public class MDC { // // public static void putSession(String session) { // org.slf4j.MDC.put("session", left(session, 9)); // } // // public static void removeSession() { // org.slf4j.MDC.remove("session"); // } // // public static void putUsername(String username) { // org.slf4j.MDC.put("username", username); // } // // public static void removeUsername() { // org.slf4j.MDC.remove("username"); // } // } // // Path: src/main/java/org/andidev/applicationname/util/StringUtils.java // public static String quote(String text) { // return "\"" + text + "\""; // }
import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.config.logging.MDC; import static org.andidev.applicationname.util.StringUtils.quote; import org.springframework.context.ApplicationListener; import org.springframework.security.core.session.SessionDestroyedEvent; import org.springframework.security.web.session.HttpSessionDestroyedEvent; import org.springframework.stereotype.Component;
package org.andidev.applicationname.config.springsecurity; @Slf4j @Component public class LogoutListener implements ApplicationListener<SessionDestroyedEvent> { @Override public void onApplicationEvent(SessionDestroyedEvent event) { String sessionId = (String) ((HttpSessionDestroyedEvent) event).getSession().getId(); String username = (String) ((HttpSessionDestroyedEvent) event).getSession().getAttribute("username"); MDC.putSession(sessionId); MDC.putUsername(username);
// Path: src/main/java/org/andidev/applicationname/config/logging/MDC.java // public class MDC { // // public static void putSession(String session) { // org.slf4j.MDC.put("session", left(session, 9)); // } // // public static void removeSession() { // org.slf4j.MDC.remove("session"); // } // // public static void putUsername(String username) { // org.slf4j.MDC.put("username", username); // } // // public static void removeUsername() { // org.slf4j.MDC.remove("username"); // } // } // // Path: src/main/java/org/andidev/applicationname/util/StringUtils.java // public static String quote(String text) { // return "\"" + text + "\""; // } // Path: src/main/java/org/andidev/applicationname/config/springsecurity/LogoutListener.java import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.config.logging.MDC; import static org.andidev.applicationname.util.StringUtils.quote; import org.springframework.context.ApplicationListener; import org.springframework.security.core.session.SessionDestroyedEvent; import org.springframework.security.web.session.HttpSessionDestroyedEvent; import org.springframework.stereotype.Component; package org.andidev.applicationname.config.springsecurity; @Slf4j @Component public class LogoutListener implements ApplicationListener<SessionDestroyedEvent> { @Override public void onApplicationEvent(SessionDestroyedEvent event) { String sessionId = (String) ((HttpSessionDestroyedEvent) event).getSession().getId(); String username = (String) ((HttpSessionDestroyedEvent) event).getSession().getAttribute("username"); MDC.putSession(sessionId); MDC.putUsername(username);
log.info("Logged out as {}", quote(username));
andidev/spring-bootstrap-enterprise
src/main/java/org/andidev/applicationname/service/GroupService.java
// Path: src/main/java/org/andidev/applicationname/entity/Group.java // @Entity // @NoArgsConstructor(access = PROTECTED) // @RequiredArgsConstructor // @Setter // @Getter // public class Group extends IdEntity implements Serializable { // // @Column(unique = true) // @NonNull // private String groupname; // @ElementCollection(targetClass = Role.class, fetch = EAGER) // @Enumerated(STRING) // private Set<Role> groupRoles = EnumSet.noneOf(Role.class); // @ManyToMany(cascade = ALL, fetch = LAZY) // private Set<User> users = new HashSet(); // @OneToMany(fetch = EAGER) // private Set<PreferenceValue> preferenceValues = new HashSet(); // } // // Path: src/main/java/org/andidev/applicationname/repository/GroupRepository.java // public interface GroupRepository extends JpaRepository<Group, Long> { // // Group findByGroupname(String groupname); // // Group findByIdNotAndGroupname(Long id, String groupname); // // Page<Group> findByGroupnameLike(Long groupname, Pageable pageable); // // }
import java.util.List; import javax.inject.Inject; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.entity.Group; import org.andidev.applicationname.repository.GroupRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional;
package org.andidev.applicationname.service; @Service @Transactional @NoArgsConstructor @AllArgsConstructor @Slf4j public class GroupService { @Inject
// Path: src/main/java/org/andidev/applicationname/entity/Group.java // @Entity // @NoArgsConstructor(access = PROTECTED) // @RequiredArgsConstructor // @Setter // @Getter // public class Group extends IdEntity implements Serializable { // // @Column(unique = true) // @NonNull // private String groupname; // @ElementCollection(targetClass = Role.class, fetch = EAGER) // @Enumerated(STRING) // private Set<Role> groupRoles = EnumSet.noneOf(Role.class); // @ManyToMany(cascade = ALL, fetch = LAZY) // private Set<User> users = new HashSet(); // @OneToMany(fetch = EAGER) // private Set<PreferenceValue> preferenceValues = new HashSet(); // } // // Path: src/main/java/org/andidev/applicationname/repository/GroupRepository.java // public interface GroupRepository extends JpaRepository<Group, Long> { // // Group findByGroupname(String groupname); // // Group findByIdNotAndGroupname(Long id, String groupname); // // Page<Group> findByGroupnameLike(Long groupname, Pageable pageable); // // } // Path: src/main/java/org/andidev/applicationname/service/GroupService.java import java.util.List; import javax.inject.Inject; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.entity.Group; import org.andidev.applicationname.repository.GroupRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; package org.andidev.applicationname.service; @Service @Transactional @NoArgsConstructor @AllArgsConstructor @Slf4j public class GroupService { @Inject
private GroupRepository groupRepository;
andidev/spring-bootstrap-enterprise
src/main/java/org/andidev/applicationname/service/GroupService.java
// Path: src/main/java/org/andidev/applicationname/entity/Group.java // @Entity // @NoArgsConstructor(access = PROTECTED) // @RequiredArgsConstructor // @Setter // @Getter // public class Group extends IdEntity implements Serializable { // // @Column(unique = true) // @NonNull // private String groupname; // @ElementCollection(targetClass = Role.class, fetch = EAGER) // @Enumerated(STRING) // private Set<Role> groupRoles = EnumSet.noneOf(Role.class); // @ManyToMany(cascade = ALL, fetch = LAZY) // private Set<User> users = new HashSet(); // @OneToMany(fetch = EAGER) // private Set<PreferenceValue> preferenceValues = new HashSet(); // } // // Path: src/main/java/org/andidev/applicationname/repository/GroupRepository.java // public interface GroupRepository extends JpaRepository<Group, Long> { // // Group findByGroupname(String groupname); // // Group findByIdNotAndGroupname(Long id, String groupname); // // Page<Group> findByGroupnameLike(Long groupname, Pageable pageable); // // }
import java.util.List; import javax.inject.Inject; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.entity.Group; import org.andidev.applicationname.repository.GroupRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional;
package org.andidev.applicationname.service; @Service @Transactional @NoArgsConstructor @AllArgsConstructor @Slf4j public class GroupService { @Inject private GroupRepository groupRepository;
// Path: src/main/java/org/andidev/applicationname/entity/Group.java // @Entity // @NoArgsConstructor(access = PROTECTED) // @RequiredArgsConstructor // @Setter // @Getter // public class Group extends IdEntity implements Serializable { // // @Column(unique = true) // @NonNull // private String groupname; // @ElementCollection(targetClass = Role.class, fetch = EAGER) // @Enumerated(STRING) // private Set<Role> groupRoles = EnumSet.noneOf(Role.class); // @ManyToMany(cascade = ALL, fetch = LAZY) // private Set<User> users = new HashSet(); // @OneToMany(fetch = EAGER) // private Set<PreferenceValue> preferenceValues = new HashSet(); // } // // Path: src/main/java/org/andidev/applicationname/repository/GroupRepository.java // public interface GroupRepository extends JpaRepository<Group, Long> { // // Group findByGroupname(String groupname); // // Group findByIdNotAndGroupname(Long id, String groupname); // // Page<Group> findByGroupnameLike(Long groupname, Pageable pageable); // // } // Path: src/main/java/org/andidev/applicationname/service/GroupService.java import java.util.List; import javax.inject.Inject; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.andidev.applicationname.entity.Group; import org.andidev.applicationname.repository.GroupRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; package org.andidev.applicationname.service; @Service @Transactional @NoArgsConstructor @AllArgsConstructor @Slf4j public class GroupService { @Inject private GroupRepository groupRepository;
public Group create(Group group) {